function Validation() {
RequireFieldValidation();
allLetter();
PasswardValidation();
EmailValidation();
MobValidation();
// if (RequireFieldValidation() == true && allLetter() == true && PasswardValidation() == true && EmailValidation() == true && MobValidation() == true) {
// return true;
// }
// else {
// return false;
// alert("error");
// }
}
function RequireFieldValidation() {
for (var i = 1; i <= 8; i++) {
var name = document.getElementById("TextBox" + i).value;
if (name == "" || name == null) {
alert("Please Enter required info in textbox "+i);
return false;
}
}
//return true;
}
function allLetter()
{
//var n = document.testJavascript.TextBox1;
var name = document.getElementById("TextBox1");
var letters = /^[A-Za-z]+$/;
if (!(name.value.match(letters))) {
alert("Please enter only alphabetic character")
return false;
}
else
{
//return false;
}
}
function PasswardValidation() {
var pwd = document.getElementById("TextBox3").value;
var rpwd = document.getElementById("TextBox4").value;
var len = pwd.length;
if (len <= 5 || len >= 11) {
alert("Please Enter Passward 6 to 10 character long");
return false;
}
else if (pwd != rpwd) {
alert("Passward doesnot match");
return false;
}
else {
// return true;
}
}
function EmailValidation() {
//var n = document.testJavascript.TextBox1;
var email = document.getElementById("TextBox5");
var mailFormate = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if (!(email.value.match(mailFormate)))
{
alert("Please enter correct email-id")
return false;
}
else
{
//return true;
}
}
function MobValidation() {
//var n = document.testJavascript.TextBox1;
var mob = document.getElementById("TextBox6");
if (isNaN(mob.value)) {
alert("Mobile no. contain incorrect character");
return false;
mob.focus();//iske liye variable mob me only getelementbyid chahiye na ki uski value.
}
else if(mob.value.length!=10){
alert("Please enter 10 digit mob no.")
mob.focus();
return false;
}
return true;
}
5 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sunny SharmaPosted Apr 30, 2013, 2:50 AM
Sunny SharmaPosted Jun 15, 2013, 4:29 AM
Thanks.
Arun KurmiPosted Jun 15, 2013, 3:58 AM
If you Seen my Stored procedure Question then Please help.
Sunny SharmaPosted Jun 15, 2013, 3:40 AM
Sorry i couldn't respond in time, did you get the solution?
Arun KurmiPosted Apr 30, 2013, 8:05 AM
1 name
2 user name
3 passward
4 retype passward
5 e-id
6 mob no
with above code my validation work expected and give alert box for every wrong input
until only and only 1 textbox remaing for entering value but when i entered value in last textbox(serial no of textbox doesnot metter it can be any one out total 6 textbox) and this value are wrong then validation do not give an error messege.for ex. when i enter wrong text for mob no in the last textbox and click on button it simply submit the form and never give an error messege.