文本框的javascript在回发事件中仅接受数字 [英] javascript for textbox accept only numbers on postback event

查看:55
本文介绍了文本框的javascript在回发事件中仅接受数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用仅允许输入数字的文本框..假设用户输入了一个字符..它必须警告消息框..我正在使用webappication开发项目.


问候
manohar

hi i am using a textbox to which only numbers are allowed..suppose a user enters a character..it must alert a messagebox.. i am doing a project in webappication


regards
manohar

推荐答案

不要警告任何东西.仅在客户端上执行此操作,并在onclick处理程序中,过滤掉除数字和退格键(字符代码8)以外的所有字符.

一种使用jQuery的简单方法.请参阅: http://www.thimbleopensource.com/tutorials-snippets/jquery-plugin -filter-text-input [ ^ ].

另请参见:
http://en.wikipedia.org/wiki/JQuery [ http://docs.jquery.com/Main_Page [
Don''t alert anything. Do it on the client side only and, in the onclick handler, filter out all characters except digits and backspace (which is character code 8).

One easy way of doing it by using jQuery. Please see: http://www.thimbleopensource.com/tutorials-snippets/jquery-plugin-filter-text-input[^].

See also:
http://en.wikipedia.org/wiki/JQuery[^],
http://docs.jquery.com/Main_Page[^].

—SA


这篇关于文本框的javascript在回发事件中仅接受数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆