dem*_*emo 2 javascript jquery firebug keypress
项目存在下一个js-function
function LoginKeyPressCheck() {
$('#txtusername, #txtpassword').keypress(function (evt) {
var charCode = (evt.which) ? evt.which : event.keyCode; // here get error
$('#Errormsg').html('');
$('#Err_ValidateUser').html('');
if (charCode === 13) {
evt.preventDefault();
$('#Err_ValidateUser').html('');
if ($.trim($('#txtusername').val()).length === 0) {
$('#Err_ValidateUser').html('Validation Error: Value is required');
}
else {
loginProcess();
}
}
});
Run Code Online (Sandbox Code Playgroud)
单击按钮时TAB出现错误"ReferenceError:event not defined".
尝试在FireBug中调试此函数,但是从行中的行var charCode = (evt.which)...光标移动else.
我无法解决问题所在.
谢谢.
改变这一行
var charCode = (evt.which) ? evt.which : evt.keyCode;
Run Code Online (Sandbox Code Playgroud)
变量事件未定义,因此您无法使用它
| 归档时间: |
|
| 查看次数: |
5031 次 |
| 最近记录: |