Mandatory Form Field not working - help needed!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AR123
    New Member
    • Mar 2007
    • 24

    Mandatory Form Field not working - help needed!

    The mandatory form field that is not working is the TYPE OF ILLUSTRATION.

    [HTML]
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>

    <head>

    <title>Proforma </title>
    <meta http-equiv=Content-Type content="text/html; charset=windows-1252">



    <script language="javas cript">

    function xxx_JScheckForm ( f )
    {

    var sErrors = "";
    var sfocusElements;
    var aCheckFields = new Array();

    aCheckFields[0] = "txt01_Name_of_ Caller:::Name of Caller";
    aCheckFields[1] = "txt02_Type_of_ Caller:::Type of Caller";
    aCheckFields[2] = "txt03_Company_ Postcode:::Comp any Postcode";
    aCheckFields[3] = "txt04_Tel_No:: :Tel No";
    aCheckFields[4] = "sel06_Type_of_ Illustration::: Type of Illustration";
    aCheckFields[5] = "txt07_Members_ Name:::Members Name";
    aCheckFields[6] = "txt08_Sex:::Da te/Time";
    aCheckFields[7] = "txt09_DOB:::DO B";
    aCheckFields[8] = "txt10_Date_Joi ned_Service:::D ate Joined Service";
    aCheckFields[9] = "txt11_Selected _Retirement_Age :::Selected Retirement Age";
    aCheckFields[10] = "txt12_Salary:: :Salary";
    aCheckFields[11] = "txt17_Comments :::Comments";



    // Loop through each field identified as mandatory
    for ( var i = 0; i < aCheckFields.le ngth; i++ )
    {
    var aData = aCheckFields[i].split( /\:\:\:/ );
    var oFormElement = eval( "f." + aData[0] );

    if ( oFormElement.va lue.match( /^\s*$/ ) )
    {
    sErrors += aData[1] + "\n";

    if ( ! sfocusElements ) { sfocusElements = aData[0]; }

    }
    }


    if ( sErrors )
    {
    alert( "The following fields are required - \n\n" + sErrors );
    eval( "f." + sfocusElements + ".focus()" );
    return false;
    }
    //Check user has selected a Type of Illustration
    if(f.sel06_Type _of_Illustratio n.value="Select "){
    alert("You must select a Type of Illustration");
    f.sel06_Type_of _Illustration.f ocus();
    return false;
    }

    //Add GBP to Employer Contribution
    //f.txt13_Employe r_Contribution. value="GBP" + f.txt13_Employe r_Contribution. value;
    //f.txt14_Employe e_Contribution. value="GBP" + f.txt14_Employe e_Contribution. value;
    alert(f.sel06_T ype_of_Illustra tion.value);
    processForm(f);
    return true;
    }

    function doThis(foo) {
    if(foo == "Option A") {
    document.forms. frmSendMail.act ion = 'http://xxxx/include/xxxx/misc/xxxx/';
    document.forms. frmSendMail.ctr lSendToEmailAdd ress.value = 'A@hotmail.co.u k';
    document.getEle mentById('email ').innerHTML = 'A@Hotmail.co.u k ';
    document.getEle mentById('optio n').innerHTML = 'Monthly Payments Only ';
    }
    else {
    if(foo == "Option B") {
    document.forms. frmSendMail.act ion = 'http://xxxx/include/xxxx/misc/xxxx/';
    document.forms. frmSendMail.ctr lSendToEmailAdd ress.value = 'B@hotmail.co.u k';
    document.getEle mentById('email ').innerHTML = 'B@hotmail.co.u k';
    document.getEle mentById('optio n').innerHTML = 'One Off Payments ';
    }

    }
    }



    function processForm(oFo rm)
    {



    oForm.txt13_Emp loyer_Contribut ion.value = "GBP " + oForm.txt13_Emp loyer_Contribut ion.value;
    oForm.txt14_Emp loyee_Contribut ion.value = "GBP " + oForm.txt14_Emp loyee_Contribut ion.value;
    }

    </script>



    <FORM name="frmSendMa il" action="" method="POST" onsubmit="retur n XXX_JScheckForm ( this )">

    <input type="hidden" name="ctrlSendT oEmailAddress" value=""/>
    <input type="hidden" name="ctrlEmail Subject" value="Proforma " />
    <input type="hidden" name="ctrlMetho d" value="E-MAIL" />
    <input type="hidden" name="ctrlFromE mailAddress" value=""/>
    <input type="hidden" name="ctrlRedir ectURL" value="/xxxxxx/submit/" />

    <table width="90%" border="0" cellspacing="0" cellpadding="0" bgcolor="8ED1E6 ">
    <tr>
    <td valign="top" align="left">
    <table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="8ED1E6 " align="center">
    <tr valign="top" align="left">
    <td class="tableBac kLightestBlue" colspan="2" height="27">
    <p style="color: #CC0000">Fields marked with * are mandatory</p>
    </td>
    </tr>


    <!-- start of form details -->

    <TR>
    <TD class="tableBac kLgtBlue2">EMAI L TYPE</td>
    <td class="tableBac kLgtBlue2">
    REQUEST
    </td>
    </tr>

    <TR>
    <TD class="tableBac kLgtBlue2">NAME OF CALLER</td>
    <td class="tableBac kLgtBlue2" style="color: #CC0000"><input type="text" name="txt01_Nam e_of_Caller"> *</td>
    </tr>

    <TR>
    <TD class="tableBac kLgtBlue2">TYPE OF CALLER</td>
    <td class="tableBac kLgtBlue2" style="color: #CC0000"><input type="text" name="txt02_Typ e_of_Caller"> *</td>
    </tr>

    <TR>
    <TD class="tableBac kLgtBlue2">COMP ANY POSTCODE</td>
    <td class="tableBac kLgtBlue2" style="color: #CC0000"><input type="text" name="txt03_Com pany_Postcode"> *</td>
    </tr>

    <TR>
    <TD class="tableBac kLgtBlue2">TELE PHONE NUMBER</td>
    <td class="tableBac kLgtBlue2" style="color: #CC0000"><input type="text" name="txt04_Tel _No"> *</td>
    </tr>

    <TR>
    <TD class="tableBac kLgtBlue2">PLAN NUMBER</td>
    <td class="tableBac kLgtBlue2" style="color: #CC0000"><input type="text" name="txt05_Pla n_No"> *</td>
    </tr>

    <TR>
    <TD class="tableBac kLgtBlue2">TYPE OF ILLUSTRATION</td>
    <td class="tableBac kLgtBlue2" style="color: #CC0000"><selec t size="1" name="sel06_Typ e_of_Illustrati on" onchange="doThi s(this.value)">
    <option value="Select"> Select</option>
    <option value="Option A">Option A</option>
    <option value="Option B">Option B</option>
    </select> *
    </td>
    </tr>

    <TR>
    <TD class="tableBac kLgtBlue2">MEMB ERS NAME</td>
    <td class="tableBac kLgtBlue2" style="color: #CC0000"><input type="text" name="txt07_Mem bers_Name"> *</td>
    </tr>

    <TR>
    <TD class="tableBac kLgtBlue2">SEX</td>
    <td class="tableBac kLgtBlue2" style="color: #CC0000"><input type="text" name="txt08_Sex "> *</td>
    </tr>

    <TR>
    <TD class="tableBac kLgtBlue2">DATE OF BIRTH</td>
    <td class="tableBac kLgtBlue2" style="color: #CC0000"><input type="text" name="txt09_DOB "> *</td>
    </tr>

    <TR>
    <TD class="tableBac kLgtBlue2">DATE JOINED SERVICE</td>
    <td class="tableBac kLgtBlue2" style="color: #CC0000"><input type="text" name="txt10_Dat e_Joined_Servic e"> *</td>
    </tr>

    <TR>
    <TD class="tableBac kLgtBlue2">SELE CTED RETIREMENT AGE</td>
    <td class="tableBac kLgtBlue2" style="color: #CC0000"><input type="text" name="txt11_Sel ected_Retiremen t_Age"> *</td>
    </tr>

    <TR>
    <TD class="tableBac kLgtBlue2">SALA RY</td>
    <td class="tableBac kLgtBlue2" style="color: #CC0000"><input type="text" name="txt12_Sal ary"> *</td>
    </tr>


    <TR>
    <TD class="tableBac kLightestBlue"> </td>
    <td class="tableBac kLightestBlue" style="color: #CC0000"><p style="color: #CC0000" id="option"></p>
    </td>
    </tr>


    <TR>
    <TD class="tableBac kLgtBlue2">EMPL OYER CONTRIBUTION</td>
    <td class="tableBac kLgtBlue2">GBP £ <input type="text" name="txt13_Emp loyer_Contribut ion">
    </tr>

    <TR>
    <TD class="tableBac kLgtBlue2">EMPL OYEE CONTRIBUTION</td>
    <td class="tableBac kLgtBlue2">GBP £ <input type="text" name="txt14_Emp loyee_Contribut ion"></td>
    </tr>

    <TR>
    <TD class="tableBac kLgtBlue2">FUND CHOICE</td>
    <td class="tableBac kLgtBlue2"><inp ut type="text" name="txt15_Fun d_Choice"></td>
    </tr>

    <TR>
    <TD class="tableBac kLgtBlue2">STAR T DATE</td>
    <td class="tableBac kLgtBlue2"><inp ut type="text" name="txt16_Sta rt_Date"></td>
    </tr>

    <tr>
    <td class="tableBac kLgtBlue2">COMM ENTS</td>
    <td class="tableBac kLgtBlue2" style="color: #CC0000"><texta rea name="txt17_Com ments" cols="30" rows="4"></textarea> *</td>
    </tr>

    <TR>
    <TD class="tableBac kLgtBlue2">TIME S</td>
    <td class="tableBac kLgtBlue2">text to go here

    </td>
    </tr>

    <TR>
    <TD class="tableBac kLgtBlue2">EMAI L RECIPIENT</td>
    <td class="tableBac kLgtBlue2"><p id="email"></p>
    </td>
    </tr>




    <tr valign="top" align="left">
    <td class="tableBac kLgtBlue2" colspan="2">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" height="19">
    <tr valign="top" align="left">
    <td width="20%">&nb sp;</td>
    <td align="center"> &nbsp; </td>
    <td align="right" width="20%">
    <INPUT TYPE="submit" class="xxxButto n" value="SEND MAIL" />
    </td>
    </tr>
    </table>
    </td>
    </tr>

    </table>
    </td>

    </tr>
    </table>

    <br><br>

    </FORM>
    </body>
    </html>[/HTML]
    Last edited by drhowarddrfine; Aug 31 '07, 02:38 PM. Reason: Please use code tags
  • ak1dnar
    Recognized Expert Top Contributor
    • Jan 2007
    • 1584

    #2
    Check this out:

    Change your codings to this way.

    [CODE=javascript]if(f.sel06_Type _of_Illustratio n.selectedIndex ==0){
    alert("You must select a Type of Illustration");
    f.sel06_Type_of _Illustration.f ocus();
    return false;
    }[/code]

    Comment

    Working...