如何限制用户输入前4是alphabtes,剩下的是javascript onkeypress事件中的数字 [英] how to restrict user to enter first 4 are alphabtes and remaining are numerics in javascript onkeypress event
本文介绍了如何限制用户输入前4是alphabtes,剩下的是javascript onkeypress事件中的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何限制用户输入前4个是字母,其余是javascript onkeypress事件中的数字
how to restrict user to enter first 4 are alphabtes and remaining are numerics in javascript onkeypress event
推荐答案
嗨Vijay,
您也可以使用javascript或jquery执行此操作。计算文本框文本的长度,如果它小于4,则检查其密钥代码。然后只允许它是alphabates。
检查以下小提琴:
http://jsfiddle.net/z721z9wy/ [ ^ ]
Hi Vijay,
You can do this with javascript or jquery also. Count the length of textbox text and if it is less than 4 then check its keycode. Then only allow if it is alphabates.
Check the following fiddle :
http://jsfiddle.net/z721z9wy/[^]
这篇关于如何限制用户输入前4是alphabtes,剩下的是javascript onkeypress事件中的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文