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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prforming Form Validation 1

Status
Not open for further replies.

blevy9

Programmer
Apr 22, 2003
16
US
I wrote function verify, that performing form verifivation.
Function loop through the all text elements of the form:


function verify(f)
{
for(var i=0; i < f.length; i++) {
var e = f.elements;
if e.value == null) {
alert(&quot;All Arguments are required for the Report&quot;);
this.focus();
return false;
}
}
return true;
}


The function is invoked from the onSubmit() event handler:
<form name=&quot;argumentdata&quot; action=&quot;preview.jsp&quot; method=&quot;get&quot; target=_top onSubmit=&quot;return verify(this);&quot;>

I don't get any errors when running script, but function does not invoked when I click Submit button of the Form.
 
forgot a parenthessis

if (e.value == null)

and if still didn't work change the null into &quot;&quot;.
 
Thank you, bnymk. I fixed error and now function verify works fine.
But now I got another problem. My script for Submit button includes onClick event, which let me get message on the screen, while retrieving data from database:

<input type=&quot;Submit&quot; value=&quot;Run Report&quot; onClick=&quot;document.getElementById('waitmsg').innerText = 'Retrieving from Database. Please Wait...'&quot;/>

<span id=&quot;waitmsg&quot;></span>

I need to get rid of this message if function verify, which I called from onSubmit event of the Form tag, return False.
Is it possible to do it?
 
I found desigion myself. I moved my call GetElementById function from onClick event into verify function if return value = true. It works fine!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top