473,395 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 3359
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

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

Similar topics

4
by: MT | last post by:
Hi all, this sounds like an easy enough thing to do, but after spending 45 minutes searching google and various javascript sites I can't find out how to make a textfield (textbox or whatever you...
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
11
by: plumba | last post by:
Hi I have a user enolment form which is users fill out to let IT know that they need setting up on 'x' systems. When the user put a cross in the 'I would like Email' checkbox I would like the...
1
by: AR123 | last post by:
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. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> ...
4
by: plumba | last post by:
Let me explain.... I have a form (most of which you guys have helped me with!!). The initial problem I was having is that it was holding the data in the fields after submit, I resolved this by...
1
by: mlshoats | last post by:
Hello I am trying to make a log to track questions i answer on little hardware problems. I got most of it working but I am very new to programming anything and just started picking up things. I am...
2
by: AR123 | last post by:
Hi I have set up a form. What I want to to is with the fields: Company Postcode Agency Number Policy Number I want these to be mandatory however if someone fills in the company postcode for...
3
by: Gaurav Jhamb | last post by:
I have 2-3 forms.On my first form when i serach to put any word it sends results and after that i click on new button in my search i got different organisation names. on the secong form i passed the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.