Jquery does not refresh the validation mailbox address implementation instance

  • 2020-03-30 01:46:23
  • OfStack

During development today. Need to authenticate mailbox in a user. However, with the traditional js no refresh need to clear the browser cache before normal validation, so I went to jquery to write a no refresh validation

<script type="text/javascript">
var ee;
function  mailbox(strEmail){
var name=document.blooger[0].email.value;
type: "get", 
url: "<?php echo "http://".$_SERVER['HTTP_HOST']."/Login/"; ?>mail.php", 
data: "youx="+name,
success: function(datax) { 
var xx = document.getElementsByName("email")[0].value;
if (xx == ""){document.getElementById("mailbox_msg").innerHTML='  <font color=red> The mailbox cannot be empty !</font>';}
else if(document.blooger[0].email.value.search(/^w+((-w+)|(.w+))*@[A-Za-z0-9]+((.|-)[A-Za-z0-9]+)*.[A-Za-z0-9]+$/) != -1) {
if (datax == 0) { 
document.getElementById("mailbox_msg").innerHTML='  <font color=red> The mailbox has been registered </font>';
else {document.getElementById("mailbox_msg").innerHTML='  <font color=green> Email address available !</font>';} 
}else{document.getElementById("mailbox_msg").innerHTML='  <font color=red> The email address is incorrect </font>';}
 function check(){
 if(ee != "1"){mailbox();return false;}

And then this is the HTML code

<form name="blooger" action="blogger.php?action=update" method="post" id="blooger" enctype="multipart/form-data" onsubmit="return check();" >
<div class="item_edit">www.jb51.net
 <?php echo $icon; ?><input type="hidden" name="photo" value="<?php echo $photo; ?>"/>
  Head portrait 
    <input name="photo" type="file" /> ( support JPG , PNG Format images )
 <li> nickname 
<input maxlength="50" style="width:185px;" value="<?php echo $nickname; ?>" name="name" /> </li>
 <li> E-mail 
<input type="text" name="email" value="<?php echo $email; ?>" id="id_mailbox" style="width:185px;" maxlength="200" onBlur="mailbox(this.value);" /><span id="mailbox_msg"></span></li>
 <li> Personal description 
<textarea name="description" style="width:300px; height:65px;" type="text" maxlength="500"><?php echo $description; ?></textarea></li>
 <li><input type="submit" value=" Save the data " class="button" /></li>

Related articles: