Mitch Swetsky
asked on
Javascript validation for numeric or null
I have a page with 3 text boxes T1,T2,T3
I want to force the user to enter numeric values or a null
The following function works for the numeric part but I need to also accept if null
function allnumeric(inputtxt)
{
var numbers = /^[0-9]+$/;
if(inputtxt.value.match(nu mbers))
{
alert('Your new number has been accepted');
document.Form_Edit.T1.focu s();
return true;
}
else
{
alert('Please input numeric characters only');
document.Form_Edit.T1.focu s();
window.history.back()
return false;
}
}
I want to force the user to enter numeric values or a null
The following function works for the numeric part but I need to also accept if null
function allnumeric(inputtxt)
{
var numbers = /^[0-9]+$/;
if(inputtxt.value.match(nu
{
alert('Your new number has been accepted');
document.Form_Edit.T1.focu
return true;
}
else
{
alert('Please input numeric characters only');
document.Form_Edit.T1.focu
window.history.back()
return false;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for the prompt reply. that works like a charm!
Open in new window