janim Posted August 7, 2007 Share Posted August 7, 2007 hi guys i really like this forum and a lot of thanks for you all ok i have registration page you know name email country .... but i found in the internet javascript msgs to prompt people who register if there any error like valid email and Full all fields .. this is the code <script type="text/javascript"> function setFocus(aField) { document.forms[0][aField].focus(); } function isAnEmailAddress(aTextField) { if (document.forms[0][aTextField].value.length<5) { return false; } else if (document.forms[0][aTextField].value.indexOf("@") < 1) { return false; } else if (document.forms[0][aTextField].value.length - document.forms[0][aTextField].value.indexOf("@") < 4) { return false; } else { return true; } } function isEmpty(aTextField) { if ((document.forms[0][aTextField].value.length==0) || (document.forms[0][aTextField].value==null)) { return true; } else { return false; } } function validate() { if (isEmpty("name")) { alert("Please fill your name."); setFocus("name"); return false; } if (isEmpty("Country")) { alert("Please fill your Country."); setFocus("con"); return false; } if (!isAnEmailAddress("email")) { alert(" The entered email address is invalid."); setFocus("email"); return false; } return true; } </script> i tried this in firefox and it's working 100% but in internet explorer it's prompt me to fill my country all the time i tried more than country and i told my friends to do all have same problem so who know what to do ? ??? ??? thanks for all :'( :'( Quote Link to comment Share on other sites More sharing options...
janim Posted August 7, 2007 Author Share Posted August 7, 2007 where are you guys ???? ??? ??? Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 7, 2007 Share Posted August 7, 2007 you should NOT use javascript to validate users inputs - or at least you should not rely on it. However it is nice to have some checks before the data is sent - it will improve the user experience by allowing the user to not have to wait for a whole page request before theya re told they did something wrong. SO make sure you check all this server side too as javascript can be turned off... Anyway to your problem.... if (isEmpty("Country")) { alert("Please fill your Country."); setFocus("con"); return false; } can you see it yet???? "Country" and "con"??? if (isEmpty("con")) { alert("Please fill your Country."); setFocus("con"); return false; } Quote Link to comment Share on other sites More sharing options...
janim Posted August 7, 2007 Author Share Posted August 7, 2007 thank you ToonMariner i tried to correct it but unfortunately :-\ same problem Quote Link to comment Share on other sites More sharing options...
mainewoods Posted August 9, 2007 Share Posted August 9, 2007 if (isEmpty("Country")) { I noticed that your field name above is capitalized but none of the other field names are capitalized. Some browsers are finicky about capitalization and id="Country" versus id="country" will not be treated the same. Quote Link to comment 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.