Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

validations php or js

Javascript validation allows your user to be informed of any errors prior to 
their submitting the form to the server. This saves irritating page-reloads 
(since on submit the JS catches the event and validates the form, preventing 
form-submission if errors are found) and minimises the chances of their having
to re-enter information again (and again and again...), or leaving prior to
completing the form properly. JS validation is not a substitute for server-side
validation (since the user can see the JS, and, by saving the page and 
amending the JS do whatever they want); but it's a convenience for them.

This is simply part of the concept of progressive enhancement, whereby JS 
provides a mechanism for enhancing the experience for the user, if it's there 
and turned on, and hopefully makes their interaction with your site pleasant,
or, at least, minimally irritating.
  
Special Note: You should ALWAYS validate in PHP on the SERVER SIDE and 
			  validation in JavaScript is CLIENT SIDE validation for user 
              CONVENIENCE. Thanks to validation on client user may find errors 
              in his form without page relodaing. But user may sent form data 
              without data script validation (for example he may not have JS 
              support in web browser), thus always validate on the server side.
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #validations #php #js
ADD COMMENT
Topic
Name
2+9 =