我有一個註冊表單,我在使用jquery檢查用戶可用性,但是當用戶不可用時,不應提交表單。如何防止它在不可用情況下提交。我的代碼是如何防止表單在用戶可用性檢查過程中提交?
$(document).ready(function(){
$('#email').change(function() {
status=0;
user=$('#email').val();
$.ajax({
type:"post",
url:"verify-user.php",
data:{'user':user},
success:function(data){
if(data=='1'){
$("#show_msg").html('<span style="color:#F00;">Not avilable</span>');
}else if(data=='0'){
$("#show_msg").html('<span style="color:#093;">Avilable</span>');
}
}
});
});
});
請幫幫我。您的幫助將不勝感激。提前致謝。
感謝您的回覆。您的代碼是好的,但是當我使用此代碼的真實條件表單提交時沒有檢查任何其他驗證手段,如果我留下其他字段空白該字段不驗證和表單提交 – Vinie