| | |
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 |
ajax apache api array back basic beginner binary broken cakephp checkbox class cms code computing cron curl database date delete display dynamic echo email error external file files filter folder form forms function functions gc_maxlifetime google host href htaccess html iframe image include insert integration ip java javascript joomla limit link login loop mail memmory memory menu mlm multiple mysql navigation oop parsing paypal pdf php problem query question radio random recursion regex remote script search server sessions sms snippet soap source space sql syntax system table thesishelp trouble tutorial update upload url validation validator variable video web xml youtube





