BillyMako Posted August 12, 2008 Share Posted August 12, 2008 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????? Quote Link to comment https://forums.phpfreaks.com/topic/119246-help-with-onblurvalidate-when-in-php/ Share on other sites More sharing options...
genericnumber1 Posted August 12, 2008 Share Posted August 12, 2008 This is actually javascript, not php. Quote Link to comment https://forums.phpfreaks.com/topic/119246-help-with-onblurvalidate-when-in-php/#findComment-614206 Share on other sites More sharing options...
monkeypaw201 Posted August 12, 2008 Share Posted August 12, 2008 I have encountered when things get finicky like that, leave the javascript OUTSIDE the PHP and put the PHP INSIDE the javascript Quote Link to comment https://forums.phpfreaks.com/topic/119246-help-with-onblurvalidate-when-in-php/#findComment-614216 Share on other sites More sharing options...
BillyMako Posted August 12, 2008 Author Share Posted August 12, 2008 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 >"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/119246-help-with-onblurvalidate-when-in-php/#findComment-614241 Share on other sites More sharing options...
Andy-H Posted August 12, 2008 Share Posted August 12, 2008 I think that he means... <input type="text" name="street" value="<?php echo $street; ?>" onBlur="validate()" /> Quote Link to comment https://forums.phpfreaks.com/topic/119246-help-with-onblurvalidate-when-in-php/#findComment-614315 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.