regex - HTML form field clearing on leave -
when tab out of html form field (5+4 zip code), field clears if i've typed 5 digits, digits remain if fill in 5+4. i'm using jquery.maskedinput
plugin masking. why don't 5 digits remain if that's type?
here's repro in jsfiddle: http://jsfiddle.net/defe8/1
<input data-val="true" data-val-length="the field claimant zip code must string maximum length of 10." data-val-length-max="10" data-val-regex="the field claimant zip code must match regular look '^(\d{5}|\d{5}-\d{4})$'." data-val-regex-pattern="^(\d{5}|\d{5}-\d{4})$" data-val-required="the claimant zip code field required." id="claimant_zip" name="claimant.zip" title="claimant zip code" type="text" value="" />
update: additional pertinent code
this attached field in question. it's part of jquery.maskedinput plugin:
$("#claimant_zip").mask("99999-9999");
as per documentation of "masked input" plugin:
by design, plugin reject input doesn't finish mask. can bypass using '?' character @ position consider input optional.
adding ?
before hyphen fixes it:
$("#claimant_zip").mask("99999?-9999");
op's jsfiddle working: http://jsfiddle.net/defe8/2/
html regex
No comments:
Post a Comment