
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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