toasty Posted January 11, 2007 Share Posted January 11, 2007 I've got this mailing list app (php/mysql) that I'm working into my website and I've got it up and running and now I'm trying to make a couple modifications to the existing code.As far as I understand the code, when someone submits an email address via the <form> tag, the script runs a javascript to check whether the email addres is composed of valid characters or if it's already in the database before processing the submission. What I want to do is configure the script so that upon a [b]successful[/b] submission an alert box pops up with a little "thank you" message (or whatever, you get the idea :) ).The existing code already throws up an alert box if the email address' format is invalid. I think the code is in here that I want to mess with, but I'm not sure where exact because I don't really know javascript.[code] <script language=JavaScript type=text/javascript>function checkNEmail(form) { if (isBlank(form.email.value) || isBlank(form.name.value) || !isEmailValid(form.email.value) ) { alert("Please enter a valid Name and Email Address .\nThe email or name you have typed in does not appear to be valid."); form.email.focus(); return false; } }function checkEmail(form) { if (isBlank(form.email.value) || !isEmailValid(form.email.value) ) { alert("Please enter a valid Email Address.\nThe email you have typed in does not appear to be valid."); form.email.focus(); return false; }return true;}function isBlank(fieldValue) { var blankSpaces = / /g; fieldValue = fieldValue.replace(blankSpaces, ""); return (fieldValue == "") ? true : false;}function isEmailValid(fieldValue) { var emailFilter = /^.+@.+\..{2,4}$/; var atSignFound = 0; for (var i = 0; i <= fieldValue.length; i++) if ( fieldValue.charAt(i) == "@" ) atSignFound++; if ( atSignFound > 1 ) return false; else return ( emailFilter.test(fieldValue) && !doesEmailHaveInvalidChar(fieldValue) ) ? true : false;}function doesEmailHaveInvalidChar(fieldValue) { var illegalChars = /[\(\)\<\>\,\;\:\\\/\"\[\] ]/; return ( illegalChars.test(fieldValue) ) ? true : false;}</script>[/code]I'm not sure if this next part helps at all, but if the email turns out valid and is [b]not[/b] already in the database, then it seems that the file [u]email_not_exist.php[/u] is called which contains this:[code] <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="38%"><div align="center">Removal Error !!!</div></td> </tr> <tr> <td> </td> </tr> <tr> <td><div align="center"> <?php echo str_replace("{email}",$email,$lang_emailexist_adress_error); ?></div></td> </tr> <tr> <td> </td> </tr></table>[/code]Thanks a lot for any ideas you all might have and I'm happy to give any more information that might help. :D Link to comment https://forums.phpfreaks.com/topic/33694-how-can-i-add-an-alert-popup-to-an-existing-if-statement/ Share on other sites More sharing options...
fenway Posted January 11, 2007 Share Posted January 11, 2007 I'm not sure why you need a alert() on success... that's the default, and what most people expect. Link to comment https://forums.phpfreaks.com/topic/33694-how-can-i-add-an-alert-popup-to-an-existing-if-statement/#findComment-158578 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.