| | |
Javascript Alert Box
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jan 2008
Posts: 16
Reputation:
Solved Threads: 0
Hi,
I have an Alert box which pops up when a customer enters in "po box" in IE7 it doesn't let the user continue after entering "po box" in the field but in Firefox after Alerting it still lets the customer continue.
How can i make it so that on all browsers the customer cannot continue unless they remove "po box" from the field???
Javascript:
PROBLEM 2:
How can i get my drop down menu to populate once the user has enter a 3 digit number in postcode which starts with an 8 only?
At the moment it populates the drop down after the 4th number is enetered but if it's a 3 digit postcode starting with 8, the user needs to manualy click the Load Suburbs button.
I have an Alert box which pops up when a customer enters in "po box" in IE7 it doesn't let the user continue after entering "po box" in the field but in Firefox after Alerting it still lets the customer continue.
How can i make it so that on all browsers the customer cannot continue unless they remove "po box" from the field???
Javascript:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
function validate() { var doc = document.create_account; var valstreet_address = new RegExp("[pP]{1}[.]*[oO]{1}[.]*[ ]*[bB]{1}[oO]{1}[xX]{1}"); if (doc.street_address.value.match(valstreet_address) != null) { alert("No P O Box Allowed in Delivery Address."); doc.street_address.focus(); } }
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<?PHP echo"<input type=text name=street_address onblur=\"validate();\" value='$street_address'>"; ?>
PROBLEM 2:
How can i get my drop down menu to populate once the user has enter a 3 digit number in postcode which starts with an 8 only?
At the moment it populates the drop down after the 4th number is enetered but if it's a 3 digit postcode starting with 8, the user needs to manualy click the Load Suburbs button.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<?php echo "<input name='postcode' type=text onkeyup=\"if(this.value.length>3)reload(this.form);else return false;\" value=$postcode>"; ?> I want it to also reload only if a 3 digit number is entered which begins with 8.
Last edited by BillyMako; Aug 20th, 2008 at 9:44 pm.
Just edit this code to match your php code.
html Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
css Syntax (Toggle Plain Text)
<style type="text/css"> <!-- form { margin: 2px 0 2px 0; padding: 0; } input, select { margin-top: 2px; padding: 2px; } --> </style>
javascript Syntax (Toggle Plain Text)
<script type="text/javascript"> <!-- BEGIN HIDING /* This would go for the validation of 3Digits entry and it should also start on with number 8. */ var post = /^[8]{1}?\d{2}$/; /* This wil filter any combination regarding about this p.o. box blocking */ var pobox = /[pP]{1}?(\w)|(\.)[oO]{1}?(\w)|(\.)[Bb]{1}[0o]{1}[Xx]{1}/; /* This goes for Solution1, just reEdit this for you php code. */ function validate(street_address) { if ( pobox.exec(street_address) ) { alert('No P O Box Allowed in Delivery Address.'); myform.street_address.focus(); return false; } else { alert('\nYour message goes here!'); } } /* This will go with Solution2, just reconfigure this 1 to match your php code*/ function pcode(pn) { if ( post.test(pn) ) { var val = myform.pn.value; var sel = document.getElementsByTagName('select')[0]; var newOpt = document.createElement('option'); var opttxt = document.createTextNode(val); newOpt.appendChild(opttxt); sel.appendChild(newOpt); newOpt.setAttribute('value', val); window.location.reload(); } else { alert('\nInvalid Entry!\nPlease Try Again.'); } } /* That does it for now and i hope this 1 helps you... Enjoy coding! */ // DONE HIDING --> </script>
html Syntax (Toggle Plain Text)
</head> <body> <form onsubmit="return false" name="myform"> City Address: <br /> <input type="text" name="street_address" onchange="validate(this.form.street_address.value);" size="20" /> <select name="list"> <option value="">PostCode</option> </select> <br /> PostCode:<br /> <input type="text" name="pn" onchange="pcode(this.form.pn.value)" size="10" /> </form> </body> </html>
Dev.Opera — FOLLOW THE STANDARDS, BREAK THE RULES...
![]() |
Similar Threads
- how can i make php alert pop ups just like in javascript. (PHP)
- Help me please in JavaScript (JavaScript / DHTML / AJAX)
- Please Help in JavaScript Problem (JavaScript / DHTML / AJAX)
- Issue with Javascript embedded in C# (ASP.NET)
- Javascript alert not working (JavaScript / DHTML / AJAX)
- Alert box, then cancel action (Javascript) (JavaScript / DHTML / AJAX)
- Beginner looking for help with Javascript (Java)
- message box (ASP.NET)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: retrieve saved password in web browser
- Next Thread: Javascript is not working in IE6
Views: 2064 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
acid2 ajax ajaxcode ajaxhelp animate api automatically beta boarder box bug calendar card checkbox child class column cookies createrange() css cursor decimal design dom download dropdown editor element error events explorer firehose flash form forms google gwt html htmlform ie8 iframe image() images index internet java javascript jawascriptruntimeerror jquery jsf jsfile jump listbox math matrixcaptcha microsoft mimic mp3 mp4 mysql object offline onmouseoutdivproblem onmouseover onreadystatechange parameters parent passing php player post problem progressbar rating regex runtime search select session shopping size sql star starrating stars stretch text textarea twitter validation w3c web website window windowofwords windowsxp wysiwyg xml xspf \n





