hi guys could you please help me I've done my script checking for input data but now I have a problem including checking for number validation in Postal Code field: here's my code and on the Postal code instead of checking for empty field I need to change it to validate number only:
function isformvalid()
{
//Load Vars from form
txtFirst_Name = document.frmValidate.txtFirst_Name.value;
//alert(txtFirst_Name);
txtSurname= document.frmValidate.txtSurname.value;
txtEmail= document.frmValidate.txtEmail.value;
txtPostal_Code= document.frmValidate.txtPostal_Code.value;
msgHeader = "The form contains the following errors:\n\n";
errMsg = "";
numErrors = 0;
var focusElement;
//First Name
if(txtFirst_Name==""{
errMsg += "Your first name is required,\n";
if(focusElement == null)
focusElement = document.frmValidate.txtFirst_Name;
document.getElementBy("firstNameError".className= "show";
numErrors = numErrors + 1;
} else {
document.getElementBy("firstNameError".className= "hide";
}
//Surname
if(txtSurname==""{
//alert("here"
errMsg += "Your Surname is required,\n";
if(focusElement == null) focusElement=document.frmValidate.txtSurname;
document.getElementById("surnameError".className = "show";
numErrors = numErrors + 1;
} else {
document.getElementById("surnameError".className = "hide";
}
//Email
if(txtEmail==""{
//alert("here"
errMsg += "Your Email is required,\n";
if(focusElement == null) focusElement = document.frmValidate.txtEmail;
document.getElementById("EmailError".className = "show";
numErrors = numErrors + 1;
} else {
document.getElementById("EmailError".className = "hide";
}
//Postal Code
if(txtPostal_Code==""{
errMsg += "Enter Postal Code is required.\n";
if(focusElement == null) focusElement = document.frmValidate.txtPostal_Code;
document.getElementById("CodeError".className = "show";
numErrors = numErrors + 1;
} else {
document.getElementById("CodeError".className = "hide";
}
//Check to see if we had any errors
if(numErrors>0){
alert(msgHeader + errMsg);
if(focusElement)
focusElement.focus();
return false;
}else{
return true;
}
}
-->
</script>
function isformvalid()
{
//Load Vars from form
txtFirst_Name = document.frmValidate.txtFirst_Name.value;
//alert(txtFirst_Name);
txtSurname= document.frmValidate.txtSurname.value;
txtEmail= document.frmValidate.txtEmail.value;
txtPostal_Code= document.frmValidate.txtPostal_Code.value;
msgHeader = "The form contains the following errors:\n\n";
errMsg = "";
numErrors = 0;
var focusElement;
//First Name
if(txtFirst_Name==""{
errMsg += "Your first name is required,\n";
if(focusElement == null)
focusElement = document.frmValidate.txtFirst_Name;
document.getElementBy("firstNameError".className= "show";
numErrors = numErrors + 1;
} else {
document.getElementBy("firstNameError".className= "hide";
}
//Surname
if(txtSurname==""{
//alert("here"
errMsg += "Your Surname is required,\n";
if(focusElement == null) focusElement=document.frmValidate.txtSurname;
document.getElementById("surnameError".className = "show";
numErrors = numErrors + 1;
} else {
document.getElementById("surnameError".className = "hide";
}
if(txtEmail==""{
//alert("here"
errMsg += "Your Email is required,\n";
if(focusElement == null) focusElement = document.frmValidate.txtEmail;
document.getElementById("EmailError".className = "show";
numErrors = numErrors + 1;
} else {
document.getElementById("EmailError".className = "hide";
}
//Postal Code
if(txtPostal_Code==""{
errMsg += "Enter Postal Code is required.\n";
if(focusElement == null) focusElement = document.frmValidate.txtPostal_Code;
document.getElementById("CodeError".className = "show";
numErrors = numErrors + 1;
} else {
document.getElementById("CodeError".className = "hide";
}
//Check to see if we had any errors
if(numErrors>0){
alert(msgHeader + errMsg);
if(focusElement)
focusElement.focus();
return false;
}else{
return true;
}
}
-->
</script>