manupug
07-13-2011, 06:10 PM
Hello I am trying to validate a web form. Someone else wrote the Html code and implemented it with an iframe using asp and php. I didn't want to mess too much with the code so I decided to use javascript to make the form validate, before it was sending email alerts with every field blank.
For the most part the validation works but it skips the email field for some reasons and is really bugging me to death. I hope that there is someone that is more experienced in javascript than me to help me find the bug. this is the code:
<head>
<link type="text/css" rel="stylesheet" href="CSS/style.css"/>
<title>Bid Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script src="gen_validatorv4.js" type="text/javascript"></script>
<script type="text/javascript">
function docload()
{
var frmvalidator = new Validator("bidrequest");
if(frmvalidator.addValidation)
{
frmvalidator.addValidation("CompanyName","req","Please enter the company Name");
frmvalidator.addValidation("CompanyName","maxlen=50","Max length for company name is 50 characters");
frmvalidator.addValidation("Contact","req","Please enter the contact name");
frmvalidator.addValidation("Contact","maxlen=30","Max length for contact name is 30 characters");
frmvalidator.addValidation("email","req","Please insert your E-mail");
frmvalidator.addValidation("Phone","req","Enter the phone number please");
frmvalidator.addValidation("Phone","maxlen=30","Max lenght is 30");
frmvalidator.addValidation("Phone","numeric","Only numbers please");
frmvalidator.addValidation("Fax","numeric","req","Enter the phone number please");
frmvalidator.addValidation("Address1","req","maxlen=100","Enter the address please");
frmvalidator.addValidation("Address2","maxlen=100");
frmvalidator.addValidation("Country","dontselect=000");
frmvalidator.addValidation("State","dontselect=000");
frmvalidator.addValidation("City","alpha","req","Please insert your City");
frmvalidator.addValidation("Zip","req","numeric");
frmvalidator.addValidation("SourceLanguage","req","Please insert the Source Language");
frmvalidator.addValidation("TargetLanguage","req","Please insert the Target Language");
/*var chktestValidator = new Validator("bidrequest");
chktestValidator.EnableOnPageErrorDisplaySingleBox();
chktestValidator.EnableMsgsTogether();
chktestValidator.addValidation("NewProject","selectradio","Is this a new project? Plese select the one'");
chktestValidator.addValidation("Revision","selectradio","Is this a Revsion? Plese select the one'");
chktestValidator.addValidation("Glossary","selectradio","Any Glossary Development? Please select one'");*/
}
}
</script>
</head>
I found the gen_validatorv4.js file online.
One more thing, if I un-commnet the radio buttons validations the whole validation stop working...weird.
I appreciate any help.
Best,
Manu
For the most part the validation works but it skips the email field for some reasons and is really bugging me to death. I hope that there is someone that is more experienced in javascript than me to help me find the bug. this is the code:
<head>
<link type="text/css" rel="stylesheet" href="CSS/style.css"/>
<title>Bid Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script src="gen_validatorv4.js" type="text/javascript"></script>
<script type="text/javascript">
function docload()
{
var frmvalidator = new Validator("bidrequest");
if(frmvalidator.addValidation)
{
frmvalidator.addValidation("CompanyName","req","Please enter the company Name");
frmvalidator.addValidation("CompanyName","maxlen=50","Max length for company name is 50 characters");
frmvalidator.addValidation("Contact","req","Please enter the contact name");
frmvalidator.addValidation("Contact","maxlen=30","Max length for contact name is 30 characters");
frmvalidator.addValidation("email","req","Please insert your E-mail");
frmvalidator.addValidation("Phone","req","Enter the phone number please");
frmvalidator.addValidation("Phone","maxlen=30","Max lenght is 30");
frmvalidator.addValidation("Phone","numeric","Only numbers please");
frmvalidator.addValidation("Fax","numeric","req","Enter the phone number please");
frmvalidator.addValidation("Address1","req","maxlen=100","Enter the address please");
frmvalidator.addValidation("Address2","maxlen=100");
frmvalidator.addValidation("Country","dontselect=000");
frmvalidator.addValidation("State","dontselect=000");
frmvalidator.addValidation("City","alpha","req","Please insert your City");
frmvalidator.addValidation("Zip","req","numeric");
frmvalidator.addValidation("SourceLanguage","req","Please insert the Source Language");
frmvalidator.addValidation("TargetLanguage","req","Please insert the Target Language");
/*var chktestValidator = new Validator("bidrequest");
chktestValidator.EnableOnPageErrorDisplaySingleBox();
chktestValidator.EnableMsgsTogether();
chktestValidator.addValidation("NewProject","selectradio","Is this a new project? Plese select the one'");
chktestValidator.addValidation("Revision","selectradio","Is this a Revsion? Plese select the one'");
chktestValidator.addValidation("Glossary","selectradio","Any Glossary Development? Please select one'");*/
}
}
</script>
</head>
I found the gen_validatorv4.js file online.
One more thing, if I un-commnet the radio buttons validations the whole validation stop working...weird.
I appreciate any help.
Best,
Manu