Pau*_*ger -1 javascript jquery
我有一个正在构建的表单 - 与任何其他表单完全相同.但是,一如既往,有一个错误:
Uncaught SyntaxError: Unexpected identifier
Run Code Online (Sandbox Code Playgroud)
以下是错误引用的脚本部分:
alert( $('#email_err').html() );
if ( checkEmail( $('#email').val() ) {
$('#email_err').html(''); //the error refers to this line
} else {
$('#email_err').html('That email address appears to be invalid');
count++;
}
Run Code Online (Sandbox Code Playgroud)
所以我的问题是alert( $('#email_err').html() );和之间的区别是什么$('#email_err').html('');?他们显然是一样的.可能有一些我忽略的东西,但我的形式的其余部分使用相同的方法完美地工作.
如果它有助于继承人的全部功能:
$(document).ready(function (e) {
$('#reg').on('submit', function (e) {
var count = 0;
e.preventDefault();
alert( $('#email_err').html() );
if ( checkEmail( $('#email').val() ) {
$('#email_err').html('');
} else {
$('#email_err').html('That email address appears to be invalid');
count++;
}
if ( $('#pass').val() === $('#c_pass').val() ) {
$('#c_pass_err').html('');
} else {
count++;
$('#c_pass_err').html('Your password don\'t appear to match, please try again.');
}
if ( count === 0 ) {
var fd = new FormData($('#reg')[0]);
$.ajax({
url:'<?php echo $dir; ?>global.func/register.php',
type:'POST',
dataType:'JSON',
processData: false,
contentType: false,
data:fd,
success: function( json ) {
if ( parseInt(json.err) === 1 ) {
$('#reg_err').html(json.err_msg);
} else { }
}
});
}
});
});
Run Code Online (Sandbox Code Playgroud)
if( checkEmail( $('#email').val() )
Run Code Online (Sandbox Code Playgroud)
失踪了).所以它应该是
if( checkEmail( $('#email').val() ) )
Run Code Online (Sandbox Code Playgroud)