Jump to content

Help with onBlur="validate();" when in PHP


BillyMako

Recommended Posts

I have this script working and now i just need the alert to pop up when the field is in PHP.

But when i put it in echo"" the onBlur event wont work.

 

function validate() {
      var valStreet = new RegExp("[pP]{1}[.]*[oO]{1}[.]*[ ]*[bB]{1}[oO]{1}[xX]{1}"); //Anything with "PO BOX" alerted

      if (form.Street.value.match(valStreet) != null) {
         alert("No P O Box Allowed in Shipping Address.");
      }   
   }
   </script>
</head>
<body><form name="test">
Street: <input type="text" name="street" value="" onBlur="validate();"><br>
<input type="button" name="test" value="test">
</form>

 

<?PHP echo"<input type='text' name='street' onBlur=\"validate();\" value=$street >"; ?>

//Something wrong with the onBlur Code!!!!

 

What is the correct way to get onBlur to work when in PHP?????

Link to comment
https://forums.phpfreaks.com/topic/119246-help-with-onblurvalidate-when-in-php/
Share on other sites

The java script is out of the php, it is the text field which needs to be inside the php and there is a problem with the onBlur="validate();" when it is inside the php echo tag.

 

There is something wrong with this line -

<?PHP echo"<input type='text' name='street' onBlur=\"validate();\" value=$street >"; ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.