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

Check for a blank numeric field

Status
Not open for further replies.

JohannIcon

Programmer
Sep 3, 2002
440
MT
Hi All

How can I check if a numeric field is empty or not? I managed to do it for text like this:-

if (field.value == "")
{
alert("You must Enter some text here")
field.focus()
field.select()
return false
}

thanks for your help
 
Try somethiong like this

Hope it helps.

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>

<html>
<head>
<title>Number Check</title>
</head>
<script>
function checkValue(){
var e = parseInt(document.f.t.value)

if( isNaN(e) ){
alert(&quot;NAN&quot; );
}
else{
alert(&quot;number&quot; );
}
return false;
}

</script>
<body>
<form action=&quot;&quot; method=&quot;post&quot; name=&quot;f&quot; id=&quot;f&quot; onsubmit=&quot;return checkValue();&quot;>
<input type=&quot;text&quot; name=&quot;t&quot;>
<input type=&quot;submit&quot; name=&quot;s&quot; value=&quot;s&quot;>
</form>


</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top