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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    enhanced form validation

    I currently have form validation but, I need for it do this: There are two radio buttons "yes I want to sign up for training" and "no i do not want to sign up". If yes is selected, the visitor should check one of the 6 training course boxes. I tried to add a script to check this but, because the other validation sends the form without running the other validation, I am not sure how to implement this. I am also not sure if the checkboxes should all be named the same or grouped. The current form validation and form is below. I have to get this form live asap and it is taking me hours to figure this out. Any help would be appreciated.

    <script language="JavaScript" type="text/JavaScript"><!--
    function VF_form1(){ //v2.0
    <!--start_of_saved_settings-->
    <!--type,radio-g,name,training,isChecked,errMsg,Please&space;select&space;whether&space;you&space;will&space;be&spa ce;attending&space;a&space;Training&space;Workshop&stop;-->
    <!--type,text,name,email,required,true,isEmail,errMsg,Email&space;is&space;required&stop;-->
    <!--type,text,name,phone,required,true,errMsg,Phone&space;is&space;required&stop;-->
    <!--type,text,name,country,required,true,errMsg,Country&space;is&space;required&stop;-->
    <!--type,text,name,zip&under;postal,required,true,errMsg,Zip&fslash;Postal&space;is&space;required&stop;-->
    <!--type,text,name,state&under;prov,required,true,errMsg,State&space;is&space;required&stop;&space;Pleas e&space;enter&space;&double;not&space;applicable&double;&space;if&space;this&space;does&space;not&sp ace;apply&stop;-->
    <!--type,text,name,city,required,true,errMsg,City&space;is&space;required&stop;-->
    <!--type,text,name,address,required,true,errMsg,Address&space;is&space;required&stop;-->
    <!--type,text,name,company,required,true,errMsg,Company&space;is&space;required&stop;-->
    <!--type,text,name,title,required,true,errMsg,Title&space;is&space;required&stop;-->
    <!--type,text,name,lastname,required,true,errMsg,Last&space;Name&space;is&space;required&stop;-->
    <!--type,text,name,firstname,required,true,errMsg,First&space;Name&space;is&space;required&stop;-->
    <!--type,select,name,sal,isDefault,errMsg,Salutation&space;is&space;required&stop;-->
    <!--end_of_saved_settings-->

    var theForm = document.forms['form1'];
    var emailRE = /(@\w[-._\w]*\w\.\w{2,3})$/;
    var rFlg_training = false;
    var sFlg_sal = false;
    var errMsg = "";
    var setfocus = "";

    for(var r14=0;r14<theForm['training'].length;r14++){if(theForm['training'][r14].checked)rFlg_training=true;}
    for(var s1=0;s1<theForm['sal'].length;s1++){if(theForm['sal'].options[s1].selected){if(theForm['sal'].options[s1].text==theForm['sal'].options[0].text)sFlg_sal=true;}}

    if (!rFlg_training){
    errMsg = "Please select whether you will be attending a Training Workshop\.";
    setfocus = "['training'][0]";
    }
    if (!emailRE.test(theForm['email'].value)){
    errMsg = "Email is required\.";
    setfocus = "['email']";
    }
    if (theForm['phone'].value == ""){
    errMsg = "Phone is required\.";
    setfocus = "['phone']";
    }
    if (theForm['country'].value == ""){
    errMsg = "Country is required\.";
    setfocus = "['country']";
    }
    if (theForm['zip_postal'].value == ""){
    errMsg = "Zip\/Postal is required\.";
    setfocus = "['zip_postal']";
    }
    if (theForm['state_prov'].value == ""){
    errMsg = "State is required\. Please enter \"not applicable\" if this does not apply\.";
    setfocus = "['state_prov']";
    }
    if (theForm['city'].value == ""){
    errMsg = "City is required\.";
    setfocus = "['city']";
    }
    if (theForm['address'].value == ""){
    errMsg = "Address is required\.";
    setfocus = "['address']";
    }
    if (theForm['company'].value == ""){
    errMsg = "Company is required\.";
    setfocus = "['company']";
    }
    if (theForm['title'].value == ""){
    errMsg = "Title is required\.";
    setfocus = "['title']";
    }
    if (theForm['lastname'].value == ""){
    errMsg = "Last Name is required\.";
    setfocus = "['lastname']";
    }
    if (theForm['firstname'].value == ""){
    errMsg = "First Name is required\.";
    setfocus = "['firstname']";
    }
    if (sFlg_sal){
    errMsg = "Salutation is required\.";
    setfocus = "['sal']";
    }
    if (errMsg != ""){
    alert(errMsg);
    eval("theForm" + setfocus + ".focus()");
    }
    function valButton(btn) {
    var cnt = -1;
    for (var i=0; i < btn.length; i++) {
    if (btn[i].checked) {cnt = i; i = btn.length;}
    }
    if (cnt > -1) return btn[cnt].value;
    else return null;
    }
    else theForm.submit();
    }
    function training_yes_clicked(){
    document.form1.wsmorning1[0].disabled=false;
    document.form1.wsmorning1[1].disabled=false;
    document.form1.wsmorning1[0].checked=false;
    document.form1.wsmorning2[0].disabled=false;
    document.form1.wsmorning2[1].disabled=false;
    document.form1.wsmorning2[0].checked=false;
    document.form1.wsnoon1[0].disabled=false;
    document.form1.wsnoon1[1].disabled=false;
    document.form1.wsnoon1[0].checked=false;
    document.form1.wsnoon2[0].disabled=false;
    document.form1.wsnoon2[1].disabled=false;
    document.form1.wsnoon2[0].checked=false;
    }
    function training_no_clicked(){
    document.form1.wsmorning1[0].disabled=true;
    document.form1.wsmorning1[1].disabled=true;
    document.form1.wsmorning2[0].disabled=true;
    document.form1.wsmorning2[1].disabled=true;
    document.form1.wsnoon1[0].disabled=true;
    document.form1.wsnoon1[1].disabled=true;
    document.form1.wsnoon2[0].disabled=true;
    document.form1.wsnoon2[1].disabled=true;

    }
    //-->
    </script>

    <form action="rtf_seattle_confirm.asp" method="post" name="form1" onSubmit="VF_form1();return false;">
    <p> <strong>Your Information</strong></p>
    <table width="100%" border="0" cellspacing="0" cellpadding="5">
    <tr>
    <td colspan="2">
    <p><strong>I would like to register for:</strong></p>
    <p><input name="conference_type" type="radio" value="Gene Expression Forum" onclick="gene_clicked();">
    Gene Expression Forum
    <input type="radio" name="conference_type" value="Protein Expression Forum" onclick="protein_clicked();">
    Protein Expression Forum</p>
    </td></tr>
    <tr valign="top">
    <td width="26%">Salutation*</td>
    <td width="74%"><select name="sal" id="sal">
    <option>----</option>
    <option value="Dr.">Dr.</option>
    <option value="Mr.">Mr.</option>
    <option value="Mrs.">Mrs.</option>
    <option value="Ms.">Ms.</option>
    </select>
    </td>
    </tr>
    <tr valign="top">
    <td>First Name*</td>
    <td><input name="firstname" type="text" id="firstname">
    </td>
    </tr>
    <tr valign="top">
    <td>Last Name*</td>
    <td><input name="lastname" type="text" id="lastname">
    </td>
    </tr>
    <tr valign="top">
    <td>Title*</td>
    <td><input name="title" type="text" id="title">
    </td>
    </tr>
    <tr valign="top">
    <td>Company*</td>
    <td><input name="company" type="text" id="company">
    </td>
    </tr>
    <tr valign="top">
    <td>Address*</td>
    <td><input name="address" type="text" id="address">
    </td>
    </tr>
    <tr valign="top">
    <td>City*</td>
    <td><input name="city" type="text" id="city">
    </td>
    </tr>
    <tr valign="top">
    <td>State/Prov*</td>
    <td><input name="state_prov" type="text" id="state_prov">
    </td>
    </tr>
    <tr valign="top">
    <td>Zip/Postal Code*</td>
    <td><input name="zip_postal" type="text" id="zip_postal">
    </td>
    </tr>
    <tr valign="top">
    <td>Country*</td>
    <td><input name="country" type="text" id="country">
    </td>
    </tr>
    <tr valign="top">
    <td>Phone*</td>
    <td><input name="phone" type="text" id="phone">
    </td>
    </tr>
    <tr valign="top">
    <td>Fax*</td>
    <td><input name="fax" type="text" id="fax"><br><font size="-2">If you do not have a fax number, <br>please enter "not applicable."</font> </td>
    </tr>
    <tr valign="top">
    <td>E-mail*</td>
    <td><input name="email" type="text" id="email">
    </td>
    </tr>
    </table>
    <p><strong>Rosetta Resolver Training Workshop Enrollment (OPTIONAL)</strong></p>
    <p><br>
    <input name="training" type="radio" value="yes" onclick="training_yes_clicked();">

    Yes, I would like to enroll in a Rosetta Resolver Version 5.0 Training Workshop. </p>
    <p>
    <input type="radio" name="training" value="no" onclick="training_no_clicked();">
    No, I am not interested in enrolling in a Rosetta Resolver Version
    5.0 Training Workshop. </p>
    <p>Mark the training workshops you would like to enroll (a maximum
    of two per day per student). You will not be charged at this time.
    After successfully completing and submitting the enrollment form,
    Rosetta Biosoftware will contact you within 2 to 3 business days
    to for payment information and complete your enrollment. Payment
    options include credit card and purchase orders.</p>
    <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC">
    <tr bgcolor="#EBEBEB">
    <td width="19%" height="29"><strong>May 24, 2005</strong></td>
    <td width="20%"><strong>Time</strong></td>
    <td width="40%"><strong>Workshops</strong></td>
    <td width="21%"><strong>Enrollment Fee</strong></td>
    </tr>
    <tr valign="top" bgcolor="#FFFFFF">
    <td align="center"><input type="checkbox" name="wsmorning1" value="5/24/05 Workshop A: Administering the Resolver&reg; System Version 5.0, 9:00 AM – 12:00 PM, Amount: $200" disabled>
    </td>
    <td>9:00 AM – 12:00 PM</td>
    <td><strong>Workshop A:</strong> Administering the Resolver&reg; System Version
    5.0</td>
    <td>$200</td>
    </tr>
    <tr valign="top" bgcolor="#FFFFFF">
    <td align="center" class="copyright"><input type="checkbox" name="wsmorning1" value="5/24/05 Workshop C: New Features in Resolver System Version 5.0, 9:00 AM – 12:00 PM, Amount: $200" disabled>
    <br>
    </td>
    <td>9:00 AM – 12:00 PM</td>
    <td><strong>Workshop C:</strong> New Features in Resolver System Version 5.0</td>
    <td>$200</td>
    </tr>
    <tr valign="top" bgcolor="#FFFFFF">
    <td height="1" colspan="4" align="center"><img src="../images/pixel.gif" width="1" height="1"></td>
    </tr>
    <tr valign="top" bgcolor="#FFFFFF">
    <td align="center"><input type="checkbox" name="wsnoon1" value="5/24/05 Workshop B: Custom Processing and Data Preparation Pipelines, 1:00 PM - 4:00 PM, Amount: $200" disabled>
    </td>
    <td>1:00 PM – 4:00 PM</td>
    <td><strong>Workshop B:</strong> Custom Processing and Data Preparation Pipelines</td>
    <td >$200</td>
    </tr>
    <tr valign="top" bgcolor="#FFFFFF">
    <td align="center" class="copyright"><input type="checkbox" name="wsnoon1" value="5/24 Workshop D: Using R with the Resolver System Version 5.0 (Use Cases), 1:00 PM - 4:00 PM, Amount: $200" disabled>
    <br>
    </td>
    <td>1:00 PM – 4:00 PM</td>
    <td><strong>Workshop D:</strong> Using R with the Resolver System Version 5.0 (Use
    Cases)</td>
    <td>$200</td>
    </tr>
    <tr valign="top" bgcolor="#ebebeb">
    <td><strong>May 27, 2005</strong></td>
    <td><strong>Time</strong></td>
    <td><strong>Workshops</strong></td>
    <td><strong>Enrollment Fee</strong></td>
    </tr>
    <tr valign="top" bgcolor="#FFFFFF">
    <td align="center"><input name="wsmorning2" type="checkbox" disabled id="wsmorning2" value="5/27/05 Workshop A: Administering the Resolver&reg; System Version 5.0, 9:00 AM - 12:00 PM, Amount: $200">
    </td>
    <td>9:00 AM – 12:00 PM</td>
    <td><strong>Workshop A: </strong>Administering the Resolver&reg; System Version
    5.0 </td>
    <td>$200</td>
    </tr>
    <tr valign="top" bgcolor="#FFFFFF">
    <td align="center"><input name="wsmorning2" type="checkbox" disabled id="wsmorning2" value="5/27/05 Workshop C: New Features in Resolver System Version 5.0, 9:00 AM - 12:00 PM, Amount: $200">
    <br>
    </td>
    <td>9:00 AM – 12:00 PM</td>
    <td><strong>Workshop C:</strong> New Features in Resolver System Version 5.0</td>
    <td>$200</td>
    </tr>
    <tr valign="top" bgcolor="#FFFFFF">
    <td height="1" colspan="4" align="center"><img src="../images/pixel.gif" width="1" height="1"></td>
    </tr>
    <tr valign="top" bgcolor="#FFFFFF">
    <td align="center"><input name="wsnoon2" type="checkbox" disabled id="wsnoon2" value="5/27/05 Workshop B: Custom Processing and Data Preparation Pipelines, 1:00 PM - 4:00 PM, Amount: $200">
    </td>
    <td>1:00 PM – 4:00 PM</td>
    <td><strong>Workshop B:</strong> Custom Processing and Data Preparation Pipelines</td>
    <td>$200</td>
    </tr>
    <tr valign="top" bgcolor="#FFFFFF">
    <td align="center"><input name="wsnoon2" type="checkbox" disabled id="wsnoon2" value="5/27/05 Workshop D: Using R with the Resolver System Version 5.0 (Use Cases), 1:00 PM - 4:00 PM, $200">
    <br>
    </td>
    <td>1:00 PM – 4:00 PM</td>
    <td><strong>Workshop D:</strong> Using R with the Resolver System Version 5.0 (Use
    Cases)</td>
    <td>$200</td>
    </tr>
    </table>
    <p>
    <p>
    <input name="Submit" type="SUBMIT" value="Submit">
    <input type="reset" name="Submit2" value="Reset">
    <br>
    </p>
    </form>

  • #2
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by beckgin
    I currently have form validation but, I need for it do this: There are two radio buttons "yes I want to sign up for training" and "no i do not want to sign up".
    Um. Why not just have a checkbox for "Yes, I want to sign up for training."?
    Forget style. Code to semantics. Seperate style from structure, and structure from behaviour.
    I code to specs, and test only in Firefox (unless stated otherwise).


  •  

    Posting Permissions

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