473,372 Members | 1,053 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,372 software developers and data experts.

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 1530
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

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

Similar topics

1
by: Le Tubs | last post by:
Hi I am wondering if anybody has come accross this problem before, basically I have to validate a xml schema (not the data, this is done at a later stage). The only problem is that there are...
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: AR123 | last post by:
The mandatory form field that is not working is the TYPE OF ILLUSTRATION. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Proforma</title> <meta...
2
by: bugsbunny12345 | last post by:
i have a form contains 7 fields .. in that if the user enters the value in any one of the field all the remaining 6 fields should be MANDATORY.. if the user didn't enter any value in any field ...
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...
6
by: Dameon99 | last post by:
Ive been looking through a whole tonne of sites to try to find out how I can make my fields mandatory but havnt been able to find something so far which actually tells me whwta I want to know. Ive...
1
by: ajd335 | last post by:
Hi.. there are some radio buttons,which are mandatory in my site. So how can i find whether they are filled by the user or not ..so that i can respond accordingly.(i.e if all mandatory fields are...
1
pradeepjain
by: pradeepjain | last post by:
Hii , I have a form which has 20-30 textboxes which are mandatory ! is there a way of validating mandatory fields in easier ways by using a single function or some thing like tht ! bcos i...
5
by: David Wright | last post by:
Hello All I am using Microsoft Access 2003. I have an input form (Single Form) into which the clerk records appliance details. Some appliance details will never change, for instance the 'Make...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.