...

View Full Version : Only numbers - critical



willjs
09-18-2006, 04:15 PM
Hi,

Somebody can help me with a function about "only number"?

I need to find a function that doesn't allows the user informs numbers.

:(

William

rlemon
09-18-2006, 05:16 PM
Hi,

Somebody can help me with a function about "only number"?

I need to find a function that doesn't allows the user informs numbers.

:(

William

First, word your question better.

Second, you should post anything you have already attempted.

http://www.codingforums.com/postguide.htm



function onlyNumbers(frmInput)
{
var re = new RegExp(/^[0-9]*$/); // regex to match only numbers
// note this regex will not match decimal values.
if(frmInput.Value.match(re))
{
alert('invalid input');
}
alert('valid input');
}

Puffin the Erb
09-18-2006, 10:11 PM
You can use the Is-Not-A-Number function :


if(isNaN(myVar))
{
alert("Not a number");
}
else
{
alert("Is a number");
}

willjs
09-18-2006, 10:25 PM
Sorry! :o

I go to post my questions better!

Thanks
William



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum