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!
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 p>
(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();
} p>
}
} },
},
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();
}
- Related articles
- New Year's greetings for the Year of the Sheep
- Set incoming calls and SMS ringtones.
- How to query your own big data
- How does the WeChat circle of friends forward the sum of words?
- It snows in Zhang Wansen. How to reply to the next sentence?
- Isn't express delivery rubbish?
- Is it difficult to file a case for online investment fraud?
- Can you find the phone records and text messages a month ago when you go to the mobile company with your ID card and mobile phone card?
- How to cancel the weather forecast in SMS?
- How to delete all address books on Android phones