本文介绍了jQuery Money蒙版输入仅带负整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图仅使用可选的负整数或正整数来屏蔽输入.我尝试使用

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

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

但是这允许任何字符都在第一位. (例如:f12,-12,+ 12,/12等.)

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.

我该怎么做?

推荐答案

实际上,我认为我找到了答案.可选添加一个整数或负号,并从掩码中减去1个9以满足要求.

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"); });

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

这篇关于jQuery Money蒙版输入仅带负整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 17:50