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

How to validate the value that user enter (only number)?

Status
Not open for further replies.

Alzayed

Programmer
Sep 9, 2000
5
0
0
KW
i need to accept form only if the enter value is numeric ,
and if not ,some alert display to the user ...

any idea ?

Thanks.
Alzayed [sig][/sig]
 
Here's a way to do it:

<script language=&quot;javascript&quot;>
<!--
function validate(txtbox)
{
if (isNaN(txtbox.value) || txtbox.value==&quot;&quot;) {
alert(&quot;Invalid Entry!&quot;);
txtbox.focus();
} else {
alert(&quot;Do whatever you would do for a proper entry!&quot;);
}

}
//-->
</script>
<form>
<input type=&quot;text&quot; name=&quot;entry&quot;>
<input type=&quot;button&quot; onClick=&quot;validate(this.form.entry);&quot;>
</form>

Regards [sig]<p>Russ<br><a href=mailto:bobbitts@hotmail.com>bobbitts@hotmail.com</a><br><a href= is in</a><br>[/sig]
 
Thanks Russ, your script solved my the problem!
and thanks nick bulka.


Alzayed.

[sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top