Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
INT + text box without isNaN
Old 06-13-2005, 07:25 PM INT + text box without isNaN
The_Anomaly's Avatar
Extreme Talker

Posts: 216
Location: Boston, Ma
Trades: 0
whats crackin, new on the forums have a quick question. i need to make a text box that will validate an integer without using the isNaN function. anyone have any idea's? o yeah, i cant use the NaN because its a homework assignment, i'm not trying to get everyone to do my homework, this one's just splitting me head open.
The_Anomaly is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-13-2005, 08:21 PM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
Try performing a mathematical calculation on it and testing the answer. Something like:
Code:
<html>
<head>
<script>
function numCheck(x)
{
	myInt = x.value;
	if ( ((myInt + 1)>=0) || ((myInt + 1)<0) )
	{
	    alert("it's valid");
	}
	else
	{
	    alert("it's invalid");
	}	
}
</script>
</head>
<body>

<input type="text" name="num" onBlur="numCheck(this);" />

</body>
</html>
__________________

Please login or register to view this content. Registration is FREE
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 06-13-2005, 08:49 PM
The_Anomaly's Avatar
Extreme Talker

Posts: 216
Location: Boston, Ma
Trades: 0
Seems to work well, only thing i was a little worried about was it didnt do anything when the box was empty. works for me though.

i tried doing a mathmatical operation on my variable to make it work like this before but i must have been doing something wrong. thx Phaedrus
The_Anomaly is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to INT + text box without isNaN
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12427 seconds with 12 queries