+ 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.

25th Jun 2019, 12:37 AM
Matheus Rodrigues
Matheus Rodrigues - avatar
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.
25th Jun 2019, 10:04 PM
Igor Makarsky
Igor Makarsky - avatar
+ 5
✅In my opinion it depends, however you can use for client side validation javascript and for server side validation you can use php.
25th Jun 2019, 3:45 PM
Nithya Yamasinghe
Nithya Yamasinghe - avatar
+ 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
25th Jun 2019, 3:44 AM
Alexander Santos
Alexander Santos - avatar
+ 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..
25th Jun 2019, 4:03 AM
Vishal Sharma
Vishal Sharma - avatar
+ 3
I think PHP but this is not an expert opinion.
25th Jun 2019, 12:48 AM
Sonic
Sonic - avatar
+ 2
thanks Igor Makarsky you facilitated a lot !
26th Jun 2019, 1:42 AM
Matheus Rodrigues
Matheus Rodrigues - avatar
+ 2
JS Coder i was hopping for this answer haha ! thanks man
26th Jun 2019, 2:39 AM
Matheus Rodrigues
Matheus Rodrigues - avatar
+ 2
No doubt PHP very modernized and sophisticated and widely recommended as per safety measures
26th Jun 2019, 3:51 PM
Aditya
Aditya - avatar
+ 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 ?
25th Jun 2019, 1:09 PM
Matheus Rodrigues
Matheus Rodrigues - avatar
+ 1
I would say PHP better
6th Jul 2019, 11:19 PM
Emad Amir
Emad Amir - avatar