Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is JavaScript validation bad?

Tags:

javascript

It has been long time since we have been validating our forms using JavaScript. I am sure this must be the case with most other developers.

Question:

What if the user (or probably a bad guy) disables JavaScript?

You are lost!

  • Is JavaScript validation worth of it?
  • Should we ever use it now?
  • Are there any solutions to this?

Correct me if I am wrong.

like image 932
Sarfraz Avatar asked Dec 22 '09 08:12

Sarfraz


People also ask

Is JavaScript validation safe?

Client side validation is NOT secure because it can easily be hacked. It is for user convenience only. For example, in response to client-side validation, the user can fix mistakes before the form is submitted. That saves the user time, and they appreciate your site.

Can we use JavaScript for validation?

HTML form validation can be done by JavaScript.

What is the advantage of using JavaScript for validation?

Increase the interactivity and usability of the web page. Make the web page more user-friendly by providing easy to use and rich features. Saves server traffic by validating user input before sending to the server. Respond immediately if there is any mistake in user data without waiting for the page reload.

Is HTML validation form good?

HTML form validation is a process of examining the HTML form page's contents to avoid errored-out data being sent to the server. This process is a significant step in developing HTML-based web applications, as it can easily improve the quality of the web page or the web application.


2 Answers

Is JavaScript validation worth of it?

Yes, as it provides a better user experience and preserves bandwidth.

Should we ever use it now?

Yes, for the aforementioned reasons.

Are there any solutions to this?

Yes, use server-side validation as well.

like image 78
Darin Dimitrov Avatar answered Sep 20 '22 14:09

Darin Dimitrov


What if the user (or probably a bad guy) disables javascript?

As said before: Simply do not rely on the client. Never do so. Check everything on the server again.

Should we ever use it now?

Yes - so the user immediately sees what's wrong. Otherwise he had to post back the data first which may take a while. By the way you reduce traffic to your server.

It's simply more inuitive.

//EDIT: BTW: The ASP.NET ValidationRules contain both client-side and server validation as far as I know.

like image 37
Matthias Avatar answered Sep 23 '22 14:09

Matthias