我只是pluged一個JQuery username check
後就正常存在的,問題是,我的形式仍然提交即使用戶名存在於我的Mysq Database
,我怎樣才能將其配置爲拒絕提交給我server side .php file
如果存在?否認提交表單,如果用戶名在MySQL數據庫
這裏是我的jQuery插件javascript代碼
$(document).ready(function() {
//the min chars for checkusername
var min_chars = 3;
//result texts
var characters_error = 'Minimum amount of chars is 3';
var checking_html = '<img src="images/checkusername.gif" /> Checking...';
//when button is clicked
$('#check_checkusername_availability').click(function(){
//run the character number check
if($('#checkusername').val().length < min_chars){
//if it's bellow the minimum show characters_error text
$('#checkusername_availability_result').html(characters_error);
}else{
//else show the cheking_text and run the function to check
$('#checkusername_availability_result').html(checking_html);
check_availability();
}
});
});
//function to check checkusername availability
function check_availability(){
//get the checkusername
var checkusername = $('#checkusername').val();
//use ajax to run the check
$.post("frontend/functions/f_checkuser.php", { checkusername: checkusername },
function(result){
//if the result is 1
if(result == 1){
//show that the checkusername is available
$('#checkusername_availability_result').html('<span class="is_available"><b>' +checkusername + '</b> is Available</span>');
}else{
//show that the checkusername is NOT available
$('#checkusername_availability_result').html('<span class="is_not_available"><b>' +checkusername + '</b> is not Available</span>');
}
});
}
這裏是我的html場
<table border="0" >
<tr>
<td valign="middle"><input class="input_field_12em required userUserName" name="userUserName" id="checkusername"></td>
<td valign="middle"><input type='button' id='check_checkusername_availability' value='Check Availability'></td>
<td><div id='checkusername_availability_result'></div></td>
</tr>
</table>
什麼形式?我看不到任何形式。那麼你可以用js禁用它。 – 2012-03-08 21:29:50
對不起,只是將html表單添加到問題 – 2012-03-08 21:32:21
「frontend/functions/f_checkuser.php」返回什麼? – ShankarSangoli 2012-03-08 21:32:46