- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Make HTML5 input type=“number” accepting dashes
To allow HTML5 input type = ”number” to accept dashes, use a regular expression.
Add the regular expression in the pattern attribute as shown below.
[ 0 - 9 ] + ([ - \, ] [0 - 9] + ) ? "
Add it to the code now:
input type = "text" pattern = "[0-9]+([-\,][0-9]+)?" name = "my-num" title = "dashes or comma"/>
The above will allow you to add dashes in number. However, above you need to use input type text for the solution to work.
Advertisements