Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How can I validate the datatype of the textbox value using javascipt? e.g. validate if data entered is decimal/int.
I'm currently validating through the if else methods.

What I have tried:

if (...)
{
}
else(...)
{
}
Posted
Updated 11-Nov-16 0:01am

1 solution

JavaScript
var value = document.getElementById('textboxID').value;
        if (isNaN(value))
            alert('not an number')
        else
            alert('valid number');


refer JavaScript isNaN() Function[^]
 
Share this answer
 
Comments
Member 12840108 13-Nov-16 23:23pm    
thanks!
Karthik_Mahalingam 15-Nov-16 0:31am    
welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900