Hari
Hari

Reputation: 43

JQuery fails in validation

In a form user should enter his mobile number.my page should check whether the length is 10.I am doing it by using jquery and disabling the submit button using .attr() function if the length is not 10. This is working properly. But using 'inspect element' option of browser, user will be able to enable the button and submit invalid mobile number.

How to solve this problem?

Upvotes: 0

Views: 33

Answers (2)

Naren
Naren

Reputation: 1

Users will always be able to by-pass front-end validation, no matter what you do. The front-end code is always sent to the user's machine to execute (JavaScript).

Validate user input in the front end to help legitimate users, but always validate user input in the back end as well to protect against malicious or curious users.

Upvotes: -1

Rory McCrossan
Rory McCrossan

Reputation: 337560

The user will always be able to add/remove attributes and elements from the DOM to make a form valid - there is absolutely nothing you can do about this.

For this reason you should always validate the received data on the server too. Client side validation is purely a convenience for the user. Server-side validation is business critical.

Upvotes: 5

Related Questions