Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
151
rated 0 times [  157] [ 6]  / answers: 1 / hits: 38853  / 8 Years ago, tue, april 19, 2016, 12:00:00

How can I return an error message to users when they try to go past the max length in a text area?



Is there a way for HTML to return an error to the user?


More From » jquery

 Answers
48
<input type=text name=fieldname maxlength=10>


You can use the maxlenght attribute to forbid entering more characters than intended. You will not need JS for this.



If you still want to use JS, then:



$(#myformid).keypress(function() {
if($(this).val().length > 10) {
//display your warinig the way you chose
}
]
});

[#62489] Sunday, April 17, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
patienceannel

Total Points: 674
Total Questions: 101
Total Answers: 101

Location: Northern Mariana Islands
Member since Fri, Jan 15, 2021
3 Years ago
patienceannel questions
Fri, Mar 11, 22, 00:00, 2 Years ago
Tue, Oct 20, 20, 00:00, 4 Years ago
Wed, Jul 24, 19, 00:00, 5 Years ago
;