Jump to content

which language is better for deleting empty input fields php or javascript?


WesleyA

Recommended Posts

What is the best way to delete empty input fields, should I use php or javascript or another language?

 

In the script the user can fill 3 or 5 input fields in the browser by html.

 

The data will be stored in the database. But empty fields shouldnt be stored.

Finally I also want to stop other crappy input, like mistakes etc.

 

Im not sure which language is used for this matter. Is it possible to use php or is javascript better?

 

My first focus is deleting empty input fields.

 

 

Link to comment
Share on other sites

You don't need to "delete" them. You just need to validate them and store only the fields that validate successfully. Preliminary validation can be done by Javascript but the final validation is always done on the server.

Link to comment
Share on other sites

You should validate with php this is a must!, JavaScript validation makes it more user friendly like when specific inputs can be highlight to identify a problem which does not require the need for the page to reload, unlike php validation, BUT! JavaScript can be disabled, that is why you need to perform php validation and sanitization before storing data in database to prevent SQL injection.

 

With html5 you have new attributes, and new type attributes values such as required, number, email etc but not all of these are supported in all browsers or older browsers versions.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...