cytsunny
cytsunny

Reputation: 5030

Is there a way to synchronize validation process of server and client side?

I have noticed that there is a similar question on stackoverflow, but it was asked in 2008 and it is now 2015. The answer points the correct direction but seems no plug-in was out at that time. I am not able to find any more recent related question on stackoverflow or google, so I decided to ask again to see if there are better tools for the problem.

When doing form validation, it is necessary to do both server side validation and client side validation. Client side validation can be by-passed easily as javascript and html can be viewed, so server side validation is necessary. Doing server side validation only is workable, but the user experience is bad due to the loading time, and it increases the burden of server.

So, is there a way I can just code the validation rule once for both server side and client side validation code?

Personally prefer php for server side but not a must.

Upvotes: 0

Views: 89

Answers (1)

asamolion
asamolion

Reputation: 848

You could use AJAX. AJAX uses javascript to communicate with the server without reloading the entire webpage. This can be used for validation purposes.

http://www.freezecoders.com/2012/10/live-check-in-database-using-php-ajax.html

If you haven't used AJAX before, you could learn at:

http://www.w3schools.com/ajax/default.asp

Upvotes: 1

Related Questions