Nida Nida - 28 days ago 19
jQuery Question

Input mask should accept five digits also

I am using jQuery input mask plugin like

var s = jQuery.noConflict();
s(document).ready(function () {
s(".zipmask").mask('99999-9999');
});


It accepts the numbers like 12345-1111 and works fine.
Now I want that it should support five digits like if we enter "12345" only, It should accept it.

Answer

You must use it like this way: Anything after the '?' is optional.

s(function(){
    s(".zipmask").mask("99999?-9999");
});