如何修复Java中输入字段无法退格的错误 [英] How to fixe bug can't backspace of input field in java

查看:62
本文介绍了如何修复Java中输入字段无法退格的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在webjava中遇到有关JavaScript的问题,为什么我不明白.

当用户在输入字段中输入内容时,我进行了编码以验证最大长度值,但是
我输入的字符串长度等于最大长度,并且我不能退格或删除任何字符.此问题仅在firefox上发生,IE可以.我想输入11个字符的字符串时可以退格或删除任何字符以编辑此字符串.
(使用代码javascript未设置属性)

希望您能尽快得到我的帮助.
我的代码:

Hi all,

I am having a problem about javascript in webjava that why i don''t understand.

I coded to validate max length value when user input into input field, but when
I input a string that it''s length equal max length and i can''t backspace or delete any char. this problem only happen on firefox, IE is ok. I want to when i input a string 11 chars and I can backspace or delete any char to edit this string.
(using code javascript not set properties)

I hope that I will be received help from you as soon as.
my code:

<head>
<script type="text/javascript">
        $(document).ready(function() {

            $("input[name='staffID']").each(function () {
                 $(this).keydown(function(event){
                     var num  = ($(this).val()).toString();
                     // only allow to input maximum 11 digit
                     if(num.length > 10){
                        return false;
                     }
                     return true;
                 });
             });
        });
    </script>
</head>

<input type="text" name="staffID" id="staffID" class="alphanum" size="8"  value="${f:h(workerNumberForm.staffID)}" />




预先感谢.




Thank in advance.

推荐答案

(document).ready(function(){
(document).ready(function() {


("input [name ='staffID ']).each(function(){
("input[name='staffID']").each(function () {


(this).keydown(function(event){ var num =(
(this).keydown(function(event){ var num = (


这篇关于如何修复Java中输入字段无法退格的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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