在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 禁止右键和 ...
随机推荐
- ios 加水印
1.加文字 -(UIImage *)addText:(UIImage *)img text:(NSString *)text1 { //get image width and ...
- if最简单的用法
/* Name:if最简单的用法-1 Copyright:By.不懂网络 Author: Yangbin Date:2014年2月9日 03:00:58 Description:if最简单的用法,真则 ...
- QTabWiget Change Color 改变颜色(每个QWidget都有一个自己的调色板palette,设置它的颜色,然后setAutoFillBackground即可)
Qt中的QTabWiget 类提供了一个便签控件,但是这个控件默认初始化的颜色是白色,和原窗口的颜色不同,看起来非常的违和,所以我们希望将其的背景颜色设为当前窗口的背景颜色.我们所要做的就是先将应用程 ...
- 《windows程序设计》学习_3.3:利用xp扫雷资源
#include<windows.h> #include "resource.h" LRESULT CALLBACK WndProc (HWND, UINT, WPAR ...
- cluster maintain manager Software群集管理软件
1,ocfs2 2,crmsh(cluster management shell,)==crm shell [pacemaker OpenAIS,heartbeat,corosync,crmsh] 3 ...
- 【解决方法】You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE)
出现场景: 正常调试是没有问题的,但是在Archive的时候,报出了这个错误. 问题详情: (null): URGENT: all bitcode will be dropped because ‘x ...
- Ping pong(树状数组经典)
Ping pong Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- Delphi Excel FastReport
unit Unit1; interface uses Printers,Windows, Messages, SysUtils, Variants, Classes, Graphics, Contro ...
- NSArray 与 NSMutableArray 的排序
由于集合的使用过程中,经常需要对数组进行排序操作,此博客用于总结对在OC中对数组排序的几种方法 1.当数组中存放的是Foundation框架中提供的对象时,直接使用 compare:方法 如:NSSt ...
- Windows系统中使用WMI获取远程服务器的信息
使用WMI获取远程服务器的状态 我做的项目里边主要包含两个内容: (1)对发布在服务器上的服务(IIS服务.WCF服务)是否可以正常访问: (2)获取服务器上的部分指标:如CPU.内存.磁盘空间信息等 ...