Jump to content

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 >"; ?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.