form validation
-
I had this form validating now it won't even run the first function. Any suggestions?
// JavaScript Document
function formValidation()
{
var uid = document.registration.userid;
var uname = document.registration.username;
var uadd = document.registration.address;
var uzip = document.registration.zip;
var uemail = document.registration.email;
if(userid_validation(uid))
{
if(allLetter(uname))
{
if(alphanumeric(uadd))
{
if(allnumeric(uzip))
{
if(ValidateEmail(uemail))
{
}
}
}
}
return false;
}
function userid_validation(uid)
{
var letters = /^[A-Za-z]+$/;
var uid_len = uid.value.length;
if (uid.value.match(letters))
{
return true;
}
else
{
alert("The First Name can not be empty/must contain only letters");
uid.focus();
return false;
}
}
function allLetter(uname)
{
var letters = /^[A-Za-z]+$/;
if (uname.value.match(letters))
{
return true;
}
else
{
alert("The Last Name can not be empty/must contain only letters");
uname.focus();
return false;
}
}
function alphanumeric(uadd, num)
{
var uadd_len = uadd.value.length;
var numbers = /^[0-9]+$/;
if (uadd.value.match(numbers))
{
return true;
}
else
{
alert("Your phone number must have a 10 digits all numbers");
uadd.focus();
return false;
}
}
function allnumeric(uzip)
{
var numbers = /^[0-9]+$/;
if (uzip.value.match(numbers))
{
return true;
}
else
{
alert("You must fill in your ZIP code with five numeric characters");
uzip.focus();
return false;
}
}
function ValidateEmail(uemail)
{
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(uemail.value.match(mailformat))
{
alert("Form Succesfully Submitted");
window.location.reload();
return true;
}
else
{
alert("You have entered an invalid email address!");
uemail.focus();
return false;
}}
-
I had this form validating now it won't even run the first function. Any suggestions?
// JavaScript Document
function formValidation()
{
var uid = document.registration.userid;
var uname = document.registration.username;
var uadd = document.registration.address;
var uzip = document.registration.zip;
var uemail = document.registration.email;
if(userid_validation(uid))
{
if(allLetter(uname))
{
if(alphanumeric(uadd))
{
if(allnumeric(uzip))
{
if(ValidateEmail(uemail))
{
}
}
}
}
return false;
}
function userid_validation(uid)
{
var letters = /^[A-Za-z]+$/;
var uid_len = uid.value.length;
if (uid.value.match(letters))
{
return true;
}
else
{
alert("The First Name can not be empty/must contain only letters");
uid.focus();
return false;
}
}
function allLetter(uname)
{
var letters = /^[A-Za-z]+$/;
if (uname.value.match(letters))
{
return true;
}
else
{
alert("The Last Name can not be empty/must contain only letters");
uname.focus();
return false;
}
}
function alphanumeric(uadd, num)
{
var uadd_len = uadd.value.length;
var numbers = /^[0-9]+$/;
if (uadd.value.match(numbers))
{
return true;
}
else
{
alert("Your phone number must have a 10 digits all numbers");
uadd.focus();
return false;
}
}
function allnumeric(uzip)
{
var numbers = /^[0-9]+$/;
if (uzip.value.match(numbers))
{
return true;
}
else
{
alert("You must fill in your ZIP code with five numeric characters");
uzip.focus();
return false;
}
}
function ValidateEmail(uemail)
{
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(uemail.value.match(mailformat))
{
alert("Form Succesfully Submitted");
window.location.reload();
return true;
}
else
{
alert("You have entered an invalid email address!");
uemail.focus();
return false;
}}
-
I had this form validating now it won't even run the first function. Any suggestions?
// JavaScript Document
function formValidation()
{
var uid = document.registration.userid;
var uname = document.registration.username;
var uadd = document.registration.address;
var uzip = document.registration.zip;
var uemail = document.registration.email;
if(userid_validation(uid))
{
if(allLetter(uname))
{
if(alphanumeric(uadd))
{
if(allnumeric(uzip))
{
if(ValidateEmail(uemail))
{
}
}
}
}
return false;
}
function userid_validation(uid)
{
var letters = /^[A-Za-z]+$/;
var uid_len = uid.value.length;
if (uid.value.match(letters))
{
return true;
}
else
{
alert("The First Name can not be empty/must contain only letters");
uid.focus();
return false;
}
}
function allLetter(uname)
{
var letters = /^[A-Za-z]+$/;
if (uname.value.match(letters))
{
return true;
}
else
{
alert("The Last Name can not be empty/must contain only letters");
uname.focus();
return false;
}
}
function alphanumeric(uadd, num)
{
var uadd_len = uadd.value.length;
var numbers = /^[0-9]+$/;
if (uadd.value.match(numbers))
{
return true;
}
else
{
alert("Your phone number must have a 10 digits all numbers");
uadd.focus();
return false;
}
}
function allnumeric(uzip)
{
var numbers = /^[0-9]+$/;
if (uzip.value.match(numbers))
{
return true;
}
else
{
alert("You must fill in your ZIP code with five numeric characters");
uzip.focus();
return false;
}
}
function ValidateEmail(uemail)
{
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(uemail.value.match(mailformat))
{
alert("Form Succesfully Submitted");
window.location.reload();
return true;
}
else
{
alert("You have entered an invalid email address!");
uemail.focus();
return false;
}}
therainking78 wrote:
if(ValidateEmail(uemail)) {
I don't see a closing '}' for this '{'
Schenectady? What am I doing in Schenectady?
-
Your first block of
if
statements does not seem correct. It can either returnfalse
or fall through to the remaining functions.One of these days I'm going to think of a really clever signature.
Thanks a ton I finally put all validated that form. Good call.
-
therainking78 wrote:
if(ValidateEmail(uemail)) {
I don't see a closing '}' for this '{'
Schenectady? What am I doing in Schenectady?
Thanks I turned on brace matching for vs2010 and picked up on it. Appreciate it. :)