Jump to content
WesleyA

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

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.

 

 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

In PHP you would use empty() to determine if the field was not filled in, then you would only store data from fields that were filled in.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...