Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
181
rated 0 times [  184] [ 3]  / answers: 1 / hits: 125305  / 10 Years ago, fri, may 2, 2014, 12:00:00

Consider:


 <input id="groupidtext" type="text" style="width: 100px;" maxlength="6" /></td>

Is there a way to set the minimum length to 6?


More From » jquery

 Answers
154

You could do it with JavaScript with something like this:


<input onblur="checkLength(this)" id="groupidtext" type="text" style="width: 100px;" maxlength="6" />
<!-- Or use event onkeyup instead if you want to check every character strike -->

function checkLength(el) {
if (el.value.length != 6) {
alert("length must be exactly 6 characters")
}
}

Note this would work in older browsers which don't support HTML 5, but it relies on the user having JavaScript switched on.


[#71205] Wednesday, April 30, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
samarab

Total Points: 620
Total Questions: 95
Total Answers: 89

Location: Bonaire
Member since Wed, May 11, 2022
2 Years ago
;