Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validate form for any selection on submit

Status
Not open for further replies.

philrm

MIS
Jun 1, 1999
58
AU
Hi ALL

We are trying to validate a form on submit. I want to check all of the input fields to make sure at least one of them has been changed. This will avoid the query extracting ALL recordes from the table.

Below is the form code I am using. Can anyone provide the code to do this validation? The four input field names are asc_order_cd, site_number, surveyorone, proj_code and factual_key as shown in the code below.

<form name=&quot;&quot; method=&quot;post&quot; action=&quot;testtwo.cfm&quot;>
<table width=&quot;673&quot; border=&quot;0&quot; height=&quot;179&quot;>
<tr>
<td>ASC:</td>
<td>
<select name=&quot;asc_order_cd&quot;>
<option value=&quot;allasc&quot; selected>(All Asc)
<cfoutput query=&quot;order&quot;>
<option value=&quot;#code# &quot;>#code# |#description#
</cfoutput>
</select>
</td>
</tr>
<tr>
<td>Site Number:</td>
<td>
<input type=&quot;text&quot; name=&quot;site_number&quot;>
</td>
</tr>
<tr>
<td>Surveyor One:</td>
<td>
<select name=&quot;surveyorone&quot;>
<option value=&quot;allsurveyor&quot; selected>(All Surveyors)
<cfoutput query=&quot;sureone&quot;>
<option value=&quot;#surveyor_code# &quot;>#surveyor_code# | #surveyor_last_name#
</cfoutput>
</select>
</td>
</tr>
<tr>
<td>Project Code:</td>
<td>
<select name=&quot;proj_code&quot;>
<option value=&quot;allprojects&quot; selected>(All Projects)
<cfoutput query=&quot;projectcode&quot;>
<option value=&quot;#project_code# &quot;>#project_code# | #project_title#
</cfoutput>
</select>
</td>
</tr>
<tr>
<td>Factual Key:</td>
<td>
<select name=&quot;factual_key&quot;>
<option value=&quot;allfactualkey&quot; selected>(All Factual Keys)
<cfoutput query=&quot;factualkey&quot;>
<option value=&quot; #code# &quot;>#code# |#description#
</cfoutput>
</select>
</td>
</tr>
</table>
<p>
<input type=&quot;submit&quot; value=&quot;Find a matching soil&quot;>
</p>
</form>
 
hmm..try something like this:


Code:
<script language=&quot;javascript&quot;><!--
function validate()
{
var validate = &quot;validated&quot;
}
function checkValidation()
{
if (validate == &quot;validated&quot;)
document.form.submit // eh..i forgot the auto-submit dealio
else
alert(&quot;Change Something&quot;);
}
//--></script>
<body>
<select onChange=&quot;validate()&quot;>
 <input type=&quot;submit&quot; value=&quot;Find a matching soil&quot;>
</form>
</body>
</i>

Hope it helps. :)

matt
 
need ta put something in...

**

<body>
<form onSubmit=&quot;checkValidation()&quot; method=&quot;post&quot; action=&quot;testtwo.cfm&quot;>
<select onChange=&quot;validate()&quot;>
<option>soforth</option>
</form>

**

stuff in red needs added (i hope..im very tired .. lol)
 
HI Dookie2k2

The code you gave me is only half functioning. What it is doing is that when, you click on this button command <input type=&quot;submit&quot; value=&quot;Find a matching soil&quot; >
IT comes up with only the alert message and then when I click OK it still process the query. It doesn't allow for a user to select a validate information before submitting it . What is going on here ?

<script language=&quot;javascript&quot;><!--
function validate()
{
var validate = &quot;validated&quot;
}
function checkValidation()
{
if (validate == &quot;validated&quot;)
document.myForm.submit // eh..i forgot the auto-submit dealio
else
alert(&quot;Change Something&quot;);
}

//-->
</script>

<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>
<form name=&quot;myForm&quot; method=&quot;post&quot; action=&quot;testtwo.cfm&quot; onSubmit=&quot;checkValidation();&quot;>
<table width=&quot;673&quot; border=&quot;0&quot; height=&quot;179&quot;>
<tr>
<td>ASC:</td>
<td>
<select name=&quot;asc_order_cd&quot; onChange=&quot;validate()&quot;>

<option value=&quot;allasc&quot; selected>(All Asc)
<cfoutput query=&quot;order&quot;>
<option value=&quot;#code# &quot;>#code# | #description#
</cfoutput>
</select>
</td>
</tr>
<tr>
<td>Site Number:</td>
<td>
<input type=&quot;text&quot; name=&quot;site_number&quot; onChange=&quot;validate()&quot;>
</td>
</tr>
<tr>
<td>Surveyor One:</td>
<td>
<select name=&quot;surveyorone&quot; onChange=&quot;validate()&quot;>
<option value=&quot;allsurveyor&quot; selected>(All Surveyors)
<cfoutput query=&quot;sureone&quot;>
<option value=&quot;#surveyor_code# &quot;>#surveyor_code# | #surveyor_last_name#
</cfoutput>
</select>
</td>
</tr>
<tr>
<td>Project Code:</td>
<td>
<select name=&quot;proj_code&quot; onChange=&quot;validate()&quot;>
<option value=&quot;allprojects&quot; selected>(All Projects)
<cfoutput query=&quot;projectcode&quot;>
<option value=&quot;#project_code# &quot;>#project_code# | #project_title#
</cfoutput>
</select>
</td>
</tr>
<tr>
<td>Factual Key:</td>
<td>
<select name=&quot;factual_key&quot; onChange=&quot;validate()&quot;>
<option value=&quot;allfactualkey&quot; selected>(All Factual Keys)
<cfoutput query=&quot;factualkey&quot;>
<option value=&quot; #code# &quot;>#code# |#description#
</cfoutput>
</select>
</td>
</tr>
</table>
<p>
<input type=&quot;submit&quot; value=&quot;Find a matching soil&quot; >
</p>
</form>
</body>
</html>
 
here we go -- this script assumes that the value of the select box is 1 thing. (in other words, it cant really tell if it changes, only if it stays the same (confusing eh))

Code:
[b]
<script language=&quot;javascript&quot;><!--
function checkValidation()
{
validate = document.form1.select1.value;
if (validate == &quot;change&quot;)
alert (&quot;You must change something&quot;);
else
document.form1.submit;
}
//--></script>
<form name=&quot;form1&quot;>
<select name=&quot;select1&quot;>
<option value=&quot;change&quot;>change me</option>
<option value=&quot;changed&quot;>changed</option>
</select>
<input type=&quot;button&quot; value=&quot;gooooo&quot; onClick=&quot;checkValidation()&quot;>
</form>
[/b]
 
Hi Dookie2k2

Anyway thank's for your help. I found a much simpler and fully functional validation for this problem. I need this to be fix by yesterday, so therefore I could not wait this long for your final reply. Thank's anyway!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top