| | |
Need to work in echo in PHP
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jan 2008
Posts: 16
Reputation:
Solved Threads: 0
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.
What is the correct way to get onBlur to work when in PHP?????
But when i put it in echo"" the onBlur event wont work.
PHP Syntax (Toggle Plain Text)
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 Syntax (Toggle Plain Text)
<?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?????
•
•
Join Date: Aug 2008
Posts: 381
Reputation:
Solved Threads: 33
I just fixed your double-quotes and it worked
Did you know that with regular expressions you can do a case-insensitive modifier and not have to do dB type stuff.
Something like this ...
...should work, but RegEx is always tricky and I didn't actually test the above
For that matter, you could probably get away with just this ...
Enjoy
PHP Syntax (Toggle Plain Text)
<html> <head> <script type="text/javascript"> 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> <?php $street = 'ez'; ?> <form name="test"> Street: <?php print "<input type=\"text\" name=\"street\" onBlur=\"validate();\" value=\"$street\" >"; ?> <!--<input type="text" name="street" value="" onBlur="validate();">--> <br> <input type="button" name="test" value="test"> </form> </body> </html>
Did you know that with regular expressions you can do a case-insensitive modifier and not have to do dB type stuff.
Something like this ...
PHP Syntax (Toggle Plain Text)
.match( /p.*?o.*?b.*?o.*?x.*/i );
For that matter, you could probably get away with just this ...
PHP Syntax (Toggle Plain Text)
.match( /.*?box/i ); // pobox, po box, post office box, mail box, postal box (all in upper and/or lower case)
Enjoy
Last edited by langsor; Aug 12th, 2008 at 2:25 am.
![]() |
Similar Threads
- php/mysql dynamic multi-level menu problem (MySQL)
- Virus scanning development using PHP (PHP)
- Open In New Window Php (PHP)
- Tearing my hair out over PHP mysql update script (PHP)
- Rss, php, javascript nightmare! help? (JavaScript / DHTML / AJAX)
- How to insert PHP in HTML language? (PHP)
- PHP/Mysql (PHP)
- Newbie Question. how to put url into echo $row (PHP)
- PHP Parse error: parse error, unexpected T_STRING (PHP)
Other Threads in the PHP Forum
- Previous Thread: insert into database problem
- Next Thread: search form with alphabetical order
| Thread Tools | Search this Thread |
# 5.2.10 access alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions sms sockets source space spam sql syntax system table tutorial update upload url validator variable video web youtube





