<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的更多相关文章

  1. C#按回车Enter使输入焦点自动跳到下一个TextBox的方法收集

    在录入界面中,用户往往需要按回车键时光标自动跳入下一个文本框,以方便录入操作.在C#中实现该功能有多种方法,以下是小编收集的不使用TAB键,而直接用回车键将光标转到下一个文本框的实现方法. 一.利用W ...

  2. js input框输入1位数字后自动跳到下一个input框聚焦

    // input框输入1位数字后自动跳到下一个input聚焦 function goNextInput(el){ var txts = document.querySelectorAll(el); f ...

  3. 在ie9下在textbox框里面输入内容按enter键会触发按钮的事件

    问题 在ie下,如果存在有button标签,如果在textbox里面输入内容,按下enter键,则会触发第一个按钮的click事件,经过测试,在IE10以及以下的都存在这个问题 原因 浏览器默认行为不 ...

  4. WPF 让Enter键按下时默认为某按钮(Button)事件

    在编写web程序时我们经常用到按Enter键来提交表单,在WPF中我们也常常需要这样的功能:例如在填写登录框信息时当填写完密码之后我希望直接按Enter键就能完成登录操作.这个需求如何来完成呢? 其实 ...

  5. JavaScript实现在textbox输入时自动去数据库匹配并找出类似值列出,选择后记得将值填入本textbox及下一个textbox

    1. <script src='<%= Application["rootURL"] %>JS/jquery-1.4.1.min.js' type="t ...

  6. 关于android软键盘enter键的替换与事件监听

    android软键盘事件监听enter键  软件盘的界面替换只有一个属性android:imeOptions,这个属性的可以取的值有 normal,actionUnspecified,actionNo ...

  7. MFC对话框程序 屏蔽ESC和ENTER键关闭对话框的方法

    http://blog.csdn.net/xgx198831/article/details/6713651 MFC对话框程序  屏蔽ESC和ENTER键关闭对话框的方法 或许还有其它更好的办法,但下 ...

  8. c# TextBox只允许输入数字,禁用右键粘贴,允许Ctrl+v粘贴数字

    TextBox只允许输入数字,最大长度为10 //TextBox.ShortcutsEnabled为false 禁止右键和Ctrl+v private void txtNumber_KeyPress( ...

  9. 2019-3-22c# TextBox只允许输入数字,禁用右键粘贴,允许Ctrl+v粘贴数字

    TextBox 禁止复制粘贴 ShortcutsEnabled =false TextBox只允许输入数字,最大长度为10 //TextBox.ShortcutsEnabled为false 禁止右键和 ...

随机推荐

  1. Ubuntu14.04 64bit安装Android-Studio

    用PPA安装Android-Studio炒鸡简单,墙内亲测可用,就是速度慢了点.(睡觉时开着电脑装-) 安装Android-Studio 打开Terminal,执行: sudo add-apt-rep ...

  2. VirtualBox 更改主机和虚拟机之间的鼠标切换热键

    VirtualBox 主机和虚拟机之间的鼠标切换热键 是 Right Ctrl.一般用惯VM Ware的都不太习惯,那么怎么改变VirtualBox鼠标切换热键呢? 1.点击菜单栏的   管理--&g ...

  3. 直接调用类成员函数地址(用汇编取类成员函数的地址,各VS版本还有所不同)

    在C++中,成员函数的指针是个比较特殊的东西.对普通的函数指针来说,可以视为一个地址,在需要的时候可以任意转换并直接调用.但对成员函数来说,常规类型转换是通不过编译的,调用的时候也必须采用特殊的语法. ...

  4. hdu 5104 Primes Problem(prime 将三重循环化两重)

    //宁用大量的二维不用量小的三维 #include <iostream> #include<cstdio> #include<cstring> using name ...

  5. Java 重写(Override)与重载(Overload)

    1.重写(Override) 重写是子类对父类的允许访问的方法的实现过程进行重新编写!返回值和形参都不能改变.即外壳不变,核心重写! 参数列表和返回值类型必须与被重写方法相同. 访问权限必须低于父类中 ...

  6. Sliding Window Maximum

    (http://leetcode.com/2011/01/sliding-window-maximum.html) A long array A[] is given to you. There is ...

  7. load_library(linker.cpp:759): library "libmaliinstr.so" not found

    1.02-07 15:19:09.277: E/linker(16043): load_library(linker.cpp:759): library "libmaliinstr.so&q ...

  8. python -- 计算数学题--用程序解决问题1

    1.#一个四位数,各位数字互不相同,所有数字之和等于6,并且这个数是11的倍数,#则满足这种要求的四位数有多少个? 代码如下: # -*- coding: UTF-8 -*-import systyp ...

  9. 修改LVDS支持1024*600分辨率

    一.在boot中增加LVDS设置分辨率1024*600选项 1.修改文件TQIMX6_android-4.2.2\bootable\bootloader\uboot-imx\common\cmd_me ...

  10. Ubuntu安装配置TFTP服务

    tftpd-hpa 是一个功能增强的TFTP服务器.它提供了很多TFTP的增强功能,它已经被移植到大多数的现代UNIX系统. 1.安装 sudo apt-get install tftpd-hpa t ...