+ 1
Which language is recommended to do form validation?
I used php in a form validation but I was told it takes more resources than javascript. and I wanted to know which one is more used on real applications? related https://www.sololearn.com/discuss/1258764/?ref=app
5 Réponses
+ 4
It depends on the validation. You should use JS if you only want to check that all the fields are not empty, validate the content of the fields, make sure that the fields have a correct format, etc. Validations in PHP are done to make sure that something will not cause an error in your database (that is, you should use it to avoid duplicate records, verify that there are no errors in the type of your variables, etc)
+ 3
The validations in JS are made interactive (depending on the event where you program them), that means that a validation of a field can be done while the user is still writing or before he sends the information.
Validations in PHP are done once the information has been sent to the server. This means that it is executed after the user has interacted with the application.
+ 2
Both. Use JS to do front end validation (tell the user what needs/doesn't need to be in the form) and use PHP for back-end validation (to make sure the user isn't trying to hack you)
0
Ok so how does the javascript and php take turns which is first executed the php or js. or does the js do it on the fly(right there on the inputs or after giving it the wrong input)?
0
ok great thanks🙏🙏