jquery money masking input with negative integer only

大憨熊 提交于 2019-12-12 04:05:19

问题


I am trying to mask input only with optional negative or positive integers. I tried using

jQuery(function($){
   $.mask.definitions['~']='[-]?';
   $("#eyescript").mask("~?999999999");
});

but this is allowing any character at the first place. (Eg: f12, -12, +12, /12, etc..)

I want the user to strictly use only '-' or any number in the first position.

How can I do this?


回答1:


Actually, I think I found the answer. Added one integer or negative sign as optional and reduced one 9 from the mask to satisfy the requirement.

jQuery(function($){ $.mask.definitions['~']='[0-9-?]'; $("#eyescript").mask("~?99999999"); });



来源:https://stackoverflow.com/questions/45949574/jquery-money-masking-input-with-negative-integer-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!