Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
169
rated 0 times [  173] [ 4]  / answers: 1 / hits: 20408  / 11 Years ago, sat, december 21, 2013, 12:00:00

I am using the inputmask from https://github.com/RobinHerbots/jquery.inputmask and applying the mask to all textboxes with class date. The problem I am having is that if the user leaves one or more of the letters from the placeholder in place, it will be accepted. For example, the user enter 10 but then clicks out of the field and the field is left with 10/dd/yyyy. How can I stop this behavior? I want to prevent the user from leaving the field when it looks like this.



here is the jQuery for the mask:



$('.date').inputmask(mm/dd/yyyy, { placeholder: mm/dd/yyyy })

More From » jquery

 Answers
0

you could use the onincomplete event to clear the input when ever is not complete





$('.date').inputmask(mm/dd/yyyy, {
placeholder: mm/dd/yyyy,
onincomplete: function() {
$(this).val('');
}
});

<script src=https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js></script>
<script src=https://rawgithub.com/RobinHerbots/jquery.inputmask/2.x/dist/jquery.inputmask.bundle.js></script>

<input type=text class=date />




[#73625] Thursday, December 19, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jackie

Total Points: 442
Total Questions: 107
Total Answers: 94

Location: Honduras
Member since Sun, Dec 26, 2021
2 Years ago
jackie questions
Sat, Sep 18, 21, 00:00, 3 Years ago
Wed, Jul 14, 21, 00:00, 3 Years ago
;