- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to limit the number of characters allowed in form input text field?
The HTML <input> tag is used to get user input in HTML. To give a limit to the input field, use the min and max attributes, which is to specify a maximum and minimum value for an input field respectively.
To limit the number of characters, use the maxlength attribute. The max and min attributes are used with number, range, date, datetime, datetime-local, month, time and week input types.
You can try to run the following code to limit the number of characters allowed in form input text field:
<!DOCTYPE html> <html> <head> <title>HTML maxlength attribute</title> </head> <body> <form action = "/cgi-bin/hello_get.cgi" method = "get"> Student Name: <br> <input type = "text" name = "first_name" value = "" maxlength = "40" /> <br> Student Subject: <br> <input type = "text" name = "last_name" value = "" maxlength = "30" /> <br> <input type = "submit" value ="Submit" /> </form> </body> </html>
- How to limit the number of characters entered in a textarea in an HTML form?
- How to give a limit to the input field in HTML?
- How to limit input text length using CSS3?
- How to limit the amount of characters returned from a field in a MongoDB?
- Which characters are NOT allowed in MongoDB field names?
- How to limit the amount of characters returned from a field in a MongoDB query?
- HTML DOM Input Text form Property
- Limit number of values in a field using MongoDB?
- Limit number of values in a field with MongoDB?
- How can we limit the number of characters inside a JTextField in Java?
- How do we add the maximum number of characters allowed in an element in HTML?
- Retrieve first 40 characters of a text field in MySQL?
- How to limit text length of EditText in Android?
- HTML DOM Input Number form Property