简体   繁体   中英

Jquery Textbox php session validation

 var x =  document.forms["myForm"]["Code2"].value;
  if (x == "") {
    alert("You cannot enter same value as previous one.");
    return false;
  }

How can i add PHP session to (x == "") so Jquery can validate previous value with current one.

index.php:


<?php $value=(isset($_SESSION['value']))?$_SESSION['value']:''; ?>
    <script type="text/javascript">
var xvalue = '<?php echo $value;?>';
    </script>

javascript file:

 var x =  document.forms["myForm"]["Code2"].value;
  if (x == xvalue) {
    alert("You cannot enter same value as previous one.");
    return false;
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM