MY JS
<script type="text/javascript">
$.extend($.fn.validatebox.defaults.rules, {
remote: {
type: "POST",
success: function(result){
var result = eval('('+result+')');
if (result.success){
} else {
alert('already exists');
}
}
}
}
</script>
<input name="username" class="easyui-validatebox" validType="remote['./include/checkusername.php','username']">
PHP代码
<?php
/* check if email is already registered */
//connect to db using mysqli
include 'connection.php';
$usern = $_POST['username'];
if(isset($_POST['username']))
{
$sql = "SELECT * FROM tblcustomers WHERE username = '"+$usern+"'";
$result = mysql_query($sql);
if($result->num_rows == 0){
echo "true";
}
else
{
echo "false";
}
}
else
{
echo "false"; //invalid post var
}
?>