• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Validate Numer only in Textbox

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am Using Java Script to validate only phone in text box using following code ...
if(isNaN(parseInt(document.frm.phone.value)))
{
alert("Enetr Number only in the Phone Column");
}
if i give the input any character (example: abcdef ) in texbox it will check and give the Correct alert message ...
but i give the input (example: 52hghg ) in textbox it will accept it .. Whenever i give the input starting with any number it will accept ..
Why? What is the Reason How to Validate number only in textbox...
 
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't call the parseInt method. Instead use


When the input is something like '52hghg', the parseInt method parses it into an integer (52 in this example). So the isNaN() method will not return a true.
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And one more thing: Next time you have a question on JavaScript (or HTML) post it in HTML and JavaScript forum.
reply
    Bookmark Topic Watch Topic
  • New Topic