在TextBox里面仅仅允许数字,按Enter键进入下一个TextBox
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="../Scripts/jquery-1.10.2.js"></script>
<style type="text/css">
body {
font-size: 9pt;
font-family: Arial;
}
</style>
<script type="text/javascript">
var specialKeys = new Array();
specialKeys.push(); //Backspace
function IsNumeric(e) {
var keyCode = e.which ? e.which : e.keyCode
var ret = ((keyCode >= && keyCode <= ) || specialKeys.indexOf(keyCode) != -);
document.getElementById("error").style.display = ret ? "none" : "inline";
return ret; } $(document).ready(function () { // Setting focus on first textbox $('input:text:first').focus(); // binding keydown event to textbox $('input:text').bind('keydown', function (e) { // detecting keycode returned from keydown and comparing if its equal to 13 (enter key code) if (e.keyCode == ) { // by default if you hit enter key while on textbox so below code will prevent that default behaviour e.preventDefault(); // getting next index by getting current index and incrementing it by 1 to go to next textbox var nextIndex = $('input:text').index(this) + ; // getting total number of textboxes on the page to detect how far we need to go var maxIndex = $('input:text').length; // check to see if next index is still smaller then max index if (nextIndex < maxIndex) { // setting index to next textbox using CSS3 selector of nth child $('input:text:eq(' + nextIndex + ')').focus(); }
} }); });
</script> </head> <body>
Numeric Value:
<input type="text" id="text1" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" />
<input type="text" id="text2" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" />
<input type="text" id="text3" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" />
<span id="error" style="color: Red; display: none">* Input digits ( - )</span>
</body> </html>
More information:
http://www.aspsnippets.com/Articles/Allow-only-numeric-value-numbers-in-TextBox-using-JavaScript.aspx
在TextBox里面仅仅允许数字,按Enter键进入下一个TextBox的更多相关文章
- C#按回车Enter使输入焦点自动跳到下一个TextBox的方法收集
在录入界面中,用户往往需要按回车键时光标自动跳入下一个文本框,以方便录入操作.在C#中实现该功能有多种方法,以下是小编收集的不使用TAB键,而直接用回车键将光标转到下一个文本框的实现方法. 一.利用W ...
- js input框输入1位数字后自动跳到下一个input框聚焦
// input框输入1位数字后自动跳到下一个input聚焦 function goNextInput(el){ var txts = document.querySelectorAll(el); f ...
- 在ie9下在textbox框里面输入内容按enter键会触发按钮的事件
问题 在ie下,如果存在有button标签,如果在textbox里面输入内容,按下enter键,则会触发第一个按钮的click事件,经过测试,在IE10以及以下的都存在这个问题 原因 浏览器默认行为不 ...
- WPF 让Enter键按下时默认为某按钮(Button)事件
在编写web程序时我们经常用到按Enter键来提交表单,在WPF中我们也常常需要这样的功能:例如在填写登录框信息时当填写完密码之后我希望直接按Enter键就能完成登录操作.这个需求如何来完成呢? 其实 ...
- JavaScript实现在textbox输入时自动去数据库匹配并找出类似值列出,选择后记得将值填入本textbox及下一个textbox
1. <script src='<%= Application["rootURL"] %>JS/jquery-1.4.1.min.js' type="t ...
- 关于android软键盘enter键的替换与事件监听
android软键盘事件监听enter键 软件盘的界面替换只有一个属性android:imeOptions,这个属性的可以取的值有 normal,actionUnspecified,actionNo ...
- MFC对话框程序 屏蔽ESC和ENTER键关闭对话框的方法
http://blog.csdn.net/xgx198831/article/details/6713651 MFC对话框程序 屏蔽ESC和ENTER键关闭对话框的方法 或许还有其它更好的办法,但下 ...
- c# TextBox只允许输入数字,禁用右键粘贴,允许Ctrl+v粘贴数字
TextBox只允许输入数字,最大长度为10 //TextBox.ShortcutsEnabled为false 禁止右键和Ctrl+v private void txtNumber_KeyPress( ...
- 2019-3-22c# TextBox只允许输入数字,禁用右键粘贴,允许Ctrl+v粘贴数字
TextBox 禁止复制粘贴 ShortcutsEnabled =false TextBox只允许输入数字,最大长度为10 //TextBox.ShortcutsEnabled为false 禁止右键和 ...
随机推荐
- C#学习日志 day 2 ------ 控制台颜色以及windowsphone 窗体应用试建
成功跑起来了hello之后,试试改变背景颜色.
- codeforces 149E . Martian Strings kmp
题目链接 给一个字符串s, n个字符串str. 令tmp为s中不重叠的两个连续子串合起来的结果, 顺序不能改变.问tmp能形成n个字符串中的几个. 初始将一个数组dp赋值为-1. 对str做kmp, ...
- poj 2155 matrix 二维线段树
题目链接 区间翻转, 单点查询, 查询操作我真是不太明白...... #include <iostream> #include <vector> #include <cs ...
- 转: Nodejs 发送HTTP POST请求实例
项目里面需要用到使用NodeJs来转发HTTP POST请求,把过程记录一下: exports.sendEmail = function (req, res) { res.send(200, req. ...
- setFocus一定要写在setLayout设置的后面,否则不起作用——使用setFocusPolicy为控件设置不同的焦点策略:Tab焦点,Click焦点,Wheel焦点和没有焦点
QLineEdit* pEditor = new QLineEdit(m_strText); pEditor->resize(.......); pEditor->move(. ...
- cocos2dx CCTextFieldTTF
CCTextFieldTTF是一个提供文本输入的控件. 先上个简单的例子 CCSize size = __winSize; CCTextFieldTTF* textEdit = CCTextField ...
- JAVA GUI学习 - JPopupMenu鼠标右键菜单组件学习
public class JPopmenuKnow { public void test() { //为表格添加鼠标右键菜单 JMenuItem jMenuItemFileInfo = new JMe ...
- 黑客瑞士军刀NC使用教程
###################################################################### 1. 写在前面的话 ################### ...
- centos6.5设备mysql5.6
1. 首先检查版本号number # uname -a 要么 # cat /etc/redhat-release CentOS release 6.6 (Final) 2. 下载并安装Mysql的yu ...
- Hadoop MapReduce链式实践--ChainReducer
版本号:CDH5.0.0,HDFS:2.3.0,Mapreduce:2.3.0,Yarn:2.3.0. 场景描写叙述:求一组数据中依照不同类别的最大值,比方,例如以下的数据: data1: A,10 ...