我點擊按鈕,什麼都沒有發生。如果我拿出驗證代碼,然後點擊該按鈕就可以工作,並回落到我已經實現的PHP驗證。我首先編寫了jQuery驗證,然後運行,然後我編寫了PHP端。但是,在PHP方面沒問題之後,jquery驗證就停止了。jquery驗證,提交按鈕不工作在php
有人可以幫忙嗎?
我嘗試添加
submitHandler: function(form) {
form.submit();
}
這樣的:
submitHandler: function(form) {
form.submit();
},
rules: {
...
}
但是什麼都沒有發生。
這裏是相關的代碼,請讓我知道如果有什麼不清楚的,謝謝!我一直堅持這一段時間。
if (isset($_POST['submit']))
{
foreach($_POST as $key=>$value)
{
unset($_SESSION[$key]);
$_SESSION[$key] = $value;
}
$errors = validation($job);
if (count($errors) == 0)
{
sendEmail($job);
sendEmailToApplicant($job);
}
}
$output = "
<script src='http://code.jquery.com/jquery-latest.js'></script>
<script type='text/javascript' src='http://jzaefferer.github.com/jquery-validation/jquery.validate.js'></script>
<script type='text/javascript'>
jQuery.validator.setDefaults({
debug: true,
success: 'valid'
});
jQuery.validator.addMethod('phoneUS', function(phone_number, element) {
phone_number = phone_number.replace(/\s+/g, '');
return this.optional(element) || phone_number.length > 9 &&
phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
}, 'Please specify a valid phone number');
</script>
<script>
$(document).ready(function(){
$('#applicationForm').validate({
rules: {
firstName: {
required: true,
rangelength: [2, 15]
},
lastName: {
required: true,
rangelength: [2, 15]
},
email: {
required: true,
email: true
},
phone: {
required: true,
phoneUS: true
},
website: {
url: true
}
}
});
});
</script>
<form id='applicationForm' name='applicationForm' method='post' enctype='multipart/form-data'>
...
<input id='submit' type='submit' name='submit' />
</form>";
哦,我爲什麼downvoted? –