Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7

Thread: Javascript bug

  1. #1
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Javascript bug

    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

  • #2
    New Coder
    Join Date
    Aug 2005
    Posts
    71
    Thanks
    9
    Thanked 3 Times in 3 Posts
    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?
    It's OK to pee against the wind if your standing in a lake.

  • #3
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    New Coder
    Join Date
    Aug 2005
    Posts
    71
    Thanks
    9
    Thanked 3 Times in 3 Posts
    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)?
    It's OK to pee against the wind if your standing in a lake.

  • #5
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    New Coder
    Join Date
    Aug 2005
    Posts
    71
    Thanks
    9
    Thanked 3 Times in 3 Posts
    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.

    http://www.javascript-coder.com/html...lidation.phtml

    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
    Code:
    frmvalidator.addValidation("email","email");
    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.
    It's OK to pee against the wind if your standing in a lake.

  • #7
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks I appreciate, I will definitely check that!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •