469,331 Members | 1,757 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,331 developers. It's quick & easy.

Mandatory Form Fields not working

24
Hi
I have set up mandatory form fields but it dosne t seem to be working. Would appreciate it if somone could have a look.

[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] = "txt02_Name_of_Caller:::Name of Caller";
aCheckFields[1] = "txt03_Type_of_Caller:::Type of Caller";
aCheckFields[2] = "txt05_Tel_No:::Tel No";
aCheckFields[3] = "txt09_Comments:::Comments";
aCheckFields[4] = "sel07_Type:::Type";
aCheckFields[5] = "txt07_Members_Name:::Members Name";
aCheckFields[6] = "txt08_Sex:::Sex";
aCheckFields[7] = "txt09_DOB:::DOB";
aCheckFields[8] = "txt10_Date_Joined_Service:::Date Joined Service";
aCheckFields[9] = "txt11_Age:::Age";
aCheckFields[10] = "txt12_Salary:::Salary";



// 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;
}

return true;

}

function doThis(foo) {
if(foo == "A") {
document.forms.frmSendMail.action = 'http://xxx/sendmail/';
document.forms.frmSendMail.ctrlSendToEmailAddress. value = 'Email@Address';
document.getElementById('email').innerHTML = 'Email@Address';
}
else {
if(foo == "B") {
document.forms.frmSendMail.action = 'http://xxx/sendmail/';
document.forms.frmSendMail.ctrlSendToEmailAddress. value = 'Email@Address';
document.getElementById('email').innerHTML = 'Email@Address';
}
else {
alert('Please pick a valid type');
}
}
}

</script>



<FORM name="frmSendMail" action="http://xxx/sendmail/" 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="/xxx/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 class="pageHead"><b>Proforma</b></p>
<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</td>
<td class="tableBackLgtBlue2" style="color: #CC0000"><select size="1" name="sel06_Type" onchange="doThis(this.value)">
<option value="Select">Select</option>
<option value="New">New</option>
<option value="Transfer">Transfer</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">AGE</td>
<td class="tableBackLgtBlue2" style="color: #CC0000"><input type="text" name="txt11_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="tableBackLgtBlue2">CONTRIBUTION</td>
<td class="tableBackLgtBlue2"><input type="text" name="txt13_Contribution"></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 17 '07 #1
1 1364
acoder
16,027 Expert Mod 8TB
Please post code using CODE tags (the # or <> buttons).

You've got your txt** numbers mixed up somehow. If you check, they don't match with the numbers in the form.
Aug 17 '07 #2

Post your reply

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

Similar topics

2 posts views Thread by AR123 | last post: by
6 posts views Thread by Dameon99 | last post: by
1 post views Thread by ajd335 | last post: by
pradeepjain
1 post views Thread by pradeepjain | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.