471,610 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,610 software developers and data experts.

Mandatory Form Field not working - help needed!

24
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="javascript">

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:::Company 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:::Date/Time";
aCheckFields[7] = "txt09_DOB:::DOB";
aCheckFields[8] = "txt10_Date_Joined_Service:::Date 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.length; i++ )
{
var aData = aCheckFields[i].split( /\:\:\:/ );
var oFormElement = eval( "f." + aData[0] );

if ( oFormElement.value.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_Illustration.value="Select"){
alert("You must select a Type of Illustration");
f.sel06_Type_of_Illustration.focus();
return false;
}

//Add GBP to Employer Contribution
//f.txt13_Employer_Contribution.value="GBP" + f.txt13_Employer_Contribution.value;
//f.txt14_Employee_Contribution.value="GBP" + f.txt14_Employee_Contribution.value;
alert(f.sel06_Type_of_Illustration.value);
processForm(f);
return true;
}

function doThis(foo) {
if(foo == "Option A") {
document.forms.frmSendMail.action = 'http://xxxx/include/xxxx/misc/xxxx/';
document.forms.frmSendMail.ctrlSendToEmailAddress. value = 'A@hotmail.co.uk';
document.getElementById('email').innerHTML = 'A@Hotmail.co.uk ';
document.getElementById('option').innerHTML = 'Monthly Payments Only ';
}
else {
if(foo == "Option B") {
document.forms.frmSendMail.action = 'http://xxxx/include/xxxx/misc/xxxx/';
document.forms.frmSendMail.ctrlSendToEmailAddress. value = 'B@hotmail.co.uk';
document.getElementById('email').innerHTML = 'B@hotmail.co.uk';
document.getElementById('option').innerHTML = 'One Off Payments ';
}

}
}



function processForm(oForm)
{



oForm.txt13_Employer_Contribution.value = "GBP " + oForm.txt13_Employer_Contribution.value;
oForm.txt14_Employee_Contribution.value = "GBP " + oForm.txt14_Employee_Contribution.value;
}

</script>



<FORM name="frmSendMail" action="" method="POST" onsubmit="return XXX_JScheckForm( this )">

<input type="hidden" name="ctrlSendToEmailAddress" value=""/>
<input type="hidden" name="ctrlEmailSubject" value="Proforma" />
<input type="hidden" name="ctrlMethod" value="E-MAIL" />
<input type="hidden" name="ctrlFromEmailAddress" value=""/>
<input type="hidden" name="ctrlRedirectURL" 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="tableBackLightestBlue" colspan="2" height="27">
<p style="color: #CC0000">Fields marked with * are mandatory</p>
</td>
</tr>


<!-- start of form details -->

<TR>
<TD class="tableBackLgtBlue2">EMAIL TYPE</td>
<td class="tableBackLgtBlue2">
REQUEST
</td>
</tr>

<TR>
<TD class="tableBackLgtBlue2">NAME OF CALLER</td>
<td class="tableBackLgtBlue2" style="color: #CC0000"><input type="text" name="txt01_Name_of_Caller"> *</td>
</tr>

<TR>
<TD class="tableBackLgtBlue2">TYPE OF CALLER</td>
<td class="tableBackLgtBlue2" style="color: #CC0000"><input type="text" name="txt02_Type_of_Caller"> *</td>
</tr>

<TR>
<TD class="tableBackLgtBlue2">COMPANY POSTCODE</td>
<td class="tableBackLgtBlue2" style="color: #CC0000"><input type="text" name="txt03_Company_Postcode"> *</td>
</tr>

<TR>
<TD class="tableBackLgtBlue2">TELEPHONE NUMBER</td>
<td class="tableBackLgtBlue2" style="color: #CC0000"><input type="text" name="txt04_Tel_No"> *</td>
</tr>

<TR>
<TD class="tableBackLgtBlue2">PLAN NUMBER</td>
<td class="tableBackLgtBlue2" style="color: #CC0000"><input type="text" name="txt05_Plan_No"> *</td>
</tr>

<TR>
<TD class="tableBackLgtBlue2">TYPE OF ILLUSTRATION</td>
<td class="tableBackLgtBlue2" style="color: #CC0000"><select size="1" name="sel06_Type_of_Illustration" onchange="doThis(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="tableBackLgtBlue2">MEMBERS NAME</td>
<td class="tableBackLgtBlue2" style="color: #CC0000"><input type="text" name="txt07_Members_Name"> *</td>
</tr>

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

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

<TR>
<TD class="tableBackLgtBlue2">DATE JOINED SERVICE</td>
<td class="tableBackLgtBlue2" style="color: #CC0000"><input type="text" name="txt10_Date_Joined_Service"> *</td>
</tr>

<TR>
<TD class="tableBackLgtBlue2">SELECTED RETIREMENT AGE</td>
<td class="tableBackLgtBlue2" style="color: #CC0000"><input type="text" name="txt11_Selected_Retirement_Age"> *</td>
</tr>

<TR>
<TD class="tableBackLgtBlue2">SALARY</td>
<td class="tableBackLgtBlue2" style="color: #CC0000"><input type="text" name="txt12_Salary"> *</td>
</tr>


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


<TR>
<TD class="tableBackLgtBlue2">EMPLOYER CONTRIBUTION</td>
<td class="tableBackLgtBlue2">GBP <input type="text" name="txt13_Employer_Contribution">
</tr>

<TR>
<TD class="tableBackLgtBlue2">EMPLOYEE CONTRIBUTION</td>
<td class="tableBackLgtBlue2">GBP <input type="text" name="txt14_Employee_Contribution"></td>
</tr>

<TR>
<TD class="tableBackLgtBlue2">FUND CHOICE</td>
<td class="tableBackLgtBlue2"><input type="text" name="txt15_Fund_Choice"></td>
</tr>

<TR>
<TD class="tableBackLgtBlue2">START DATE</td>
<td class="tableBackLgtBlue2"><input type="text" name="txt16_Start_Date"></td>
</tr>

<tr>
<td class="tableBackLgtBlue2">COMMENTS</td>
<td class="tableBackLgtBlue2" style="color: #CC0000"><textarea name="txt17_Comments" cols="30" rows="4"></textarea> *</td>
</tr>

<TR>
<TD class="tableBackLgtBlue2">TIMES</td>
<td class="tableBackLgtBlue2">text to go here

</td>
</tr>

<TR>
<TD class="tableBackLgtBlue2">EMAIL RECIPIENT</td>
<td class="tableBackLgtBlue2"><p id="email"></p>
</td>
</tr>




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

</table>
</td>

</tr>
</table>

<br><br>

</FORM>
</body>
</html>[/HTML]
Aug 31 '07 #1
1 3281
ak1dnar
1,584 Expert 1GB
Check this out:

Change your codings to this way.

Expand|Select|Wrap|Line Numbers
  1. if(f.sel06_Type_of_Illustration.selectedIndex==0){
  2.         alert("You must select a Type of Illustration");
  3.         f.sel06_Type_of_Illustration.focus();
  4.         return false;
  5.     }
Aug 31 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by MT | last post: by
2 posts views Thread by AR123 | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by
1 post views Thread by ZEDKYRIE | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.