Need to Learn javaScript form validation!
i want to learn a bit about javaScript form validation(coding and开发者_StackOverflow中文版 as well as theory).Can you give me the links for the tutorials(apart from w3schools). And make sure that i dont to learn in depth, because i need to learn this for exam purposes only, not for my feature use.
The classical simple case of form validation:
- there is .js function that returns false or true
- this .js function is called on submit action of form
- if valiation is NOT OK,that submit is not performed ,due to .js returned false
.js(validation of e-mail):
function validator(){
var reg = ".+@.+\\.[a-z]+";
if (document.getElementById('inputId').innerHTML().match(reg)){
return true;
} else (return false);
}
.html:
<form onsubmit="return validator();">
...
</form>
You may start with variation of this case
There is no "JavaScript form validation" as a single feature. If you want to use plain JavaScript you have to do all the work yourself.
- Iterating your Form Elements
- Checking if they are valid (depending on their type)
- and generating User Feedback if not.
the javascript knowledge that you need for that is pretty basic.
A really great location where you can find all information you need to know is the Mozilla JavaScript Guide.
https://developer.mozilla.org/en/JavaScript/Guide
btw: its devided in useful chapters so if you dont want to, you dont have to learn that in depth. (But i would recommend it).
精彩评论