Joke Collection Website - Blessing messages - How to use jquery.validate.js for remote in tp framework

How to use jquery.validate.js for remote in tp framework

There are two methods of remote. The verification between remote and PHP is introduced as follows

(1) meta String method (of course, this method requires the introduction of jquery.metadata.js)

p>

The following is my HTML code

class="input {validate:{required:true,telphoneValid:

true,remote:'moblie_register.php?fun=moblie',

messages:{required:'Please enter your mobile phone number! ' ,

telphoneValid:'Please enter the correct mobile phone number',remote:'This mobile phone number has been registered!

Log in? /a>'}}}" />

Submit remotely directly to the PHP page.

The default submission type is GET submission

PHP code:

if ($_GET['fun']=='moblie') {//Check whether the mobile phone has been registered

$moblie_number=trim($_GET['moblie']);

$exists_moblie=$db->query_first("select acc_moblie_number from t_account where

acc_moblie_number=' ".$moblie_number."'");

if (empty($exists_moblie['acc_moblie_number'])) {

$return['type']='true';

$return['info']='This mobile phone number can be registered! ';

}else{

$return['type']='false';

$return['info']='The mobile phone number Already registered! ';

}

exit($return['type']);

}

This completes the verification

(2) rules method

$("#Form2").validate({

rules: { //Define validation rules, where the attribute name is the form name attribute

"mail_account": {

required: true,

email: true,

remote: {

url: '<--?php echo $this--->base;?-->/maileckmail',

type: 'POST',

dateType: 'json',

data: { mail_account:function(){

return $('#mail_account').val();

}

}

} },

},

messages: {

"mail_account": {

email: "Please enter the correct email address (for example, myemail@qq.com)",

remote: "The email already exists!"

},

p>

}

});

PHP code:

function checkMail(){

$mail_account = $_POST ['mail_account'];

if($this->Mail->findByMailAccount($mail_account))

echo 'false';

else

p>

echo 'true';

die();

}