I have a simple textbox in which users enter number.
Does jQuery have a isDigit function that will allow me to show an alert box if users ente
Forget regular expressions. JavaScript has a builtin function for this: isNaN():
isNaN(123) // false
isNaN(-1.23) // false
isNaN(5-2) // false
isNaN(0) // false
isNaN("100") // false
isNaN("Hello") // true
isNaN("2005/12/12") // true
Just call it like so:
if (isNaN( $("#whatever").val() )) {
// It isn't a number
} else {
// It is a number
}