Javascript 在firefox JSP中验证textfield onkeypress事件

Javascript 在firefox JSP中验证textfield onkeypress事件,javascript,jsp,firefox,onkeypress,Javascript,Jsp,Firefox,Onkeypress,我已经编写了onKeyPress事件,当用户输入一些文本,然后从某个字段中弹出标签时,该事件将验证文本,如果未输入任何内容或输入了错误的值,则应给出错误信息以通知用户,焦点应返回到该字段,并且不允许用户进入下一个字段,而不是字段的“帮助”按钮 <jade:input type="text" name="dtxtDesigCd" value="" size="10" maxlength="8" classname="input" disabledclass="disabl

我已经编写了onKeyPress事件,当用户输入一些文本,然后从某个字段中弹出标签时,该事件将验证文本,如果未输入任何内容或输入了错误的值,则应给出错误信息以通知用户,焦点应返回到该字段,并且不允许用户进入下一个字段,而不是字段的“帮助”按钮

<jade:input type="text" name="dtxtDesigCd" 
    value="" size="10" maxlength="8" 
    classname="input" disabledclass="disabled-input" style="color: black"  
    datasource="dsDesigHourDetail:desigCode"
    onkeypress= "checkDesignation(this, event);">
</jade:input> 
现在已被替换为

    onkeypress= "checkDesignation(this, event);">
JSP中帮助按钮/选取列表的代码如下:

<rap:pickfromlist name="picklistDesignation" datasource="dsDesigHourDetail" 
    pflheading="Designation Details" focusfield="dtxtDesigCd"
    pflcolumnsdesc="Designation Code, Description" 
    fieldlist="distinct emp_desig_cd, emp_desig_desc " 
    lookuptable="pmm_designation" orderby="emp_desig_cd"
    targetproperty="desigCode, designation" 
    whereclause=" executive_post='N' and crew_flg = 'N'" /> 
检查这个

    $("#textbox").bind("onKeyPress ", function (e) {
                if (e.altKey || e.ctrlKey || e.shiftKey){
                    return true;
    }
    else{
    // you have this text box inner text in this.val() and can be checked with 
           your validate function.
    }
            });

你写得很好。现在确切的问题是什么?
<jade:input type="text" name="dlblDesigDesc" value="" size="50" 
    classname="labeltext" style="color: black" 
    datasource="dsDesigHourDetail:designation" enabled="False">
</jade:input>
function checkDesignation(obj, evt) {
    var evt = (evt) ? evt : (window.event) ? event : null;
    if (evt) {
        var len = TrimString(obj.value).length;
        alert("Designation : " + obj.value);
        if (evt.keyCode == 9 && len >= 0) {
            if (len == 0) {
                setErrMessage('Designation must be entered and not blank');
                document.forms[0].htmlPageTopContainer_pageForm_detailDesigHourForm_dtxtDesigCd.focus();
                document.forms[0].htmlPageTopContainer_pageForm_detailDesigHourForm_dtxtDesigCd.value = '';
                setValue('DESIGNATION');
                return false;
            } else {
                capitalize(obj);
                setValue('DESIGNATION');
                return true;
            }
        }
    }
} 
    $("#textbox").bind("onKeyPress ", function (e) {
                if (e.altKey || e.ctrlKey || e.shiftKey){
                    return true;
    }
    else{
    // you have this text box inner text in this.val() and can be checked with 
           your validate function.
    }
            });