View Full Version : Javascript bug

07-13-2011, 07: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:

<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");
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("City","alpha","req","Please insert your City");
frmvalidator.addValidation("SourceLanguage","req","Please insert the Source Language");
frmvalidator.addValidation("TargetLanguage","req","Please insert the Target Language");

/*var chktestValidator = new Validator("bidrequest");

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'");*/

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.



07-13-2011, 07:25 PM
Just a thought, it appears "email" is all lower case where everything else is mixed (Upper/Lower). Could this be the reason the validation skips?

07-13-2011, 08:04 PM
I thought about it, and I changed to be the same, but I get the same results.

The first "email" is calling the function in the js file and the "req" is calling the function int he js file, meaning that is required, the 3rd field is the message the pops on the screen.

I should post the js file uh? but is huge and I haven't touched it at all.

07-13-2011, 08:27 PM
ok, I had a look at the validation program. I wanted to clarify something. are you saying that on your form, if you leave the email field blank it doesn't catch that or are you saying that is does not check for the proper syntax of the email address (something@something.com)?

07-13-2011, 09:04 PM
you can leave it blank and the validation will go the next field in my case the phone number. The script should catch the format of the email too, whatever@whatever.com it does not check if the email is an existing email address though and I do not care actually.

07-13-2011, 09:12 PM
ok, it appears there may be a problem with the form validator script. go here and to download the script and check it against the one you have to make sure they are the same.


also, if you want to validate the email syntax, it appears you need to add this line to your code right below the "email, req" line


aside from that, you may want to post your question on their website to see if they have an answer for you since you are using their script.

07-13-2011, 09:37 PM
Thanks I appreciate, I will definitely check that!