JavaScript provides a way to validate form's data on the client's computer before sending it to the web server. Form validation generally performs custom functions.
Check value null or empty
|
function CheckValNullOrNOT(str) {
if (typeof str == 'undefined' || !str || str.length === 0 || str === "" || !/[^\s]/.test(str) || /^\s*$/.test(str) || str.replace(/\s/g, "") === "") {
return false;
}
else {
return true;
}
}
|
Check email valid or not
|
function CheckEmail(val) {
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(val)) {
return false;
} else {
return true;
}
}
|