• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

input only numbers with HTML

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to input only numbers in HTML or javascript. What are different ways for this? Thanks.
 
Greenhorn
Posts: 6
Python Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well basicly there are two ways. Javascript on keypress event or HTML5 number type.
 
Marshal
Posts: 69410
276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ST: that looks promising. Both of you: welcome to the Ranch
 
Ranch Hand
Posts: 59
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(1) Need it more than once then use it as a function:


(2)At particular then use inline coding:



 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in <!DOCTYPE html> you can directly use



And in javascript for validation you can make a function;






To know further validations you can refer or try below code for which i post a link:

https://jsfiddle.net/emkey08/zgvtjc51


 
This will take every ounce of my mental strength! All for a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic