重定向点输入上的下一个文本框 [英] Redirect next textbox on dot enter

查看:80
本文介绍了重定向点输入上的下一个文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文本框,一个为美元,另一个为美分...我要进行JavaScript验证..美元的文本框应仅接受数字和点运算符...如果我按."从我的键盘应该跳到下一个仅接受数字的框(美分).但是我尝试考虑字符.".运算符,即"190" ...但是它是通过键盘而不是数字键盘来工作的..我的客户希望从数字键盘''来操作它.按.....请帮助

HI I have two textboxes one for dollars and another for cents.....i want javascript validation..dollar textbox shoud accept only numbers and dot operator...if i press "." from my keyboard it should jump to next box(cents) which also accepts only numbers..However I tried considering charcode of "." operator i.e."190"...but its working from keyboard but not number pad..My CLIENT wants it from number pad ''.'' press.....please help

推荐答案

使用带有或条件(用于小数点)的键代码110.

关键代码列表

http://www.cambiaresearch.com/articles/15/javascript-char-codes-键代码 [ ^ ]
Use key code 110 with OR condition which is for decimal point.

list of key codes

http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes[^]


您可以使用onkeydownonkeypress事件捕获事件键代码,然后按Tab键代码.

在文本框中尝试这样的操作:
You can use onkeydown or onkeypress event to trap the event keycode and then press tab keycode.

Try something like this for the textbox:
<input type="text" onkeydown="EnterToTab()">


JS代码:


JS code:

function EnterToTab(){
  if (event.keyCode==110)
    event.keyCode=9;
  }


从此处选择适当的键码: JavaScript字符码(键码) [ ^ ]-看起来像根据您的情况而定为110.

PS:这是不建议使用的,因为Enter和Tab具有两个不同的功能来执行和使用它们,这并不是很好.


Pick the appropriate keycode from here: Javascript Char Codes (Key Codes)[^] - Looks like it''s 110 for your case.

PS: This is not suggestible as Enter and Tab have two different functions to perform and playing with them like this not good.


这篇关于重定向点输入上的下一个文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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