+ 6
Which language is better to validate forms ?
Guys, which language do you recommend for validate forms, JavaScript or PHP ? I would like too creat a register sistem, but i need to validate too.
12 Respostas
+ 20
I use both as every other web developer. Here are some examples:
1. Username must be at least 3 characters long.
Use Javascript. It can handle it and it's the fastest way.
2. Username must be unique.
If you store usernames in a database (MYSQL, I Postgresql and similar), the most effective way of validation will be with PHP.
3. Username must contain only Latin letters.
Javascript has a solution to this.
Basically, if validation requires comparison to database values - use PHP. If it doesn't - use Javascript.
P.S. Anyone can take JS code from your website, because it is public. But no one can replace your code with theirs. It requires access to your server.
+ 5
✅In my opinion it depends, however you can use for client side validation javascript and for server side validation you can use php.
+ 4
Better is all questionable.
For less complex experience, i would say PHP. But if you have some experience on JS, doing it at Node may sound better for you
+ 4
I think js is better among all because it is better to validate the form on the local browser rather than sending query to the server...and then validating the details..
+ 3
I think PHP but this is not an expert opinion.
+ 2
thanks Igor Makarsky you facilitated a lot !
+ 2
JS Coder i was hopping for this answer haha ! thanks man
+ 2
No doubt PHP very modernized and sophisticated and widely recommended as per safety measures
+ 1
Thanks guys, but its true that php is more safe ? someone told me that anyone can change the code of js and put bad information, it is true ?
+ 1
I would say PHP better