I have a form in which a user is asked to input their email address...and then asked to input the address again right below it and I want a popup alert that won't allow for the addresses to be different...And I already have a form validation checking to see if all required fields on the entire form are filled out so this would be just for the email address. ???
1/15/2006 4:24:27 PM
if(document.form.email1.value!=document.form.email2.value) { alert("n00b"); document.form.email1.value= ""; document.form.email2.value="";}[Edited on January 15, 2006 at 7:42 PM. Reason : like that?]
1/15/2006 7:23:04 PM
well...the thing is that wouldn't there need to be a 'submit' button or something to call that function? and if so, that wouldn't work because they don't submit the form until the very end of the form... is there such a way to make an onFocus event so that after they re-enter their email if it doesn't match then the alert comes up otherwise it just lets it go?
1/17/2006 4:17:37 PM
use the onBlur event to call your javascript function
1/17/2006 4:25:24 PM
Now THAT'S funny.... onBlur!!!But really, Ima try it....
1/17/2006 4:50:18 PM
ok...so then how would I change the code to say something like:function valid(form){var input1=email address entered in the first box;input=document.myform.data.value; if (input2==input1){alert("Please enter the same address");}}I know it's messy...and I know somewhere I'd have to say basically that if email1 does not equal email2, then popup the alert, else nothing...but I'm confusing myself and now I'm totally lost[Edited on January 17, 2006 at 5:24 PM. Reason : ]
1/17/2006 5:23:30 PM
OK...I got this far, and it works fine if it's on it's own page...but the minute I put it on the page with the other items, I'm getting an error?
<SCRIPT LANGUAGE="JavaScript">function valid(form){var input1=document.myform.email1.value;var input2=document.myform.email2.value; if (input2!==input1){alert("Please enter the same address");}}</SCRIPT>
1/17/2006 5:51:31 PM
^the '!==' should be '!='if you have your two boxes like
Email 1: <input type='text' name='email1'><br><input type='text' name='email2' onBlur='valid()'>
<script>function valid() { if (document.myform.email1.value!=document.myform.email2.value){ alert("Please enter the same address"); document.myform.email1.value=""; document.myform.email2.value=""; }}</script>
1/17/2006 5:54:52 PM
damn it...I'm still getting an error message...., it's telling me that document.form.email1 is null or not an object
1/17/2006 6:06:15 PM
did you name the form?just go off of this: http://www.codelifter.com/main/javascript/emailaddresschecker1.html[Edited on January 17, 2006 at 6:36 PM. Reason : yep]
1/17/2006 6:29:45 PM
mother fucker kJ FhkJhfkjS fhkjf hkjsdh;SHdf
1/17/2006 8:24:24 PM
ok...maybe the problem is that I have a form within a form...which according to some things I've read...you can't have that... is there any other way to have an onBlur event without it being a form? And I mean it would actually have to do the checking of the data and everything...so does this mean I'm SOL?
1/17/2006 8:34:14 PM
why do you need a form within a form?
1/17/2006 8:35:05 PM
because I have form with many questions on it...some are required, other's not... and IN the form, when it asks for a person's email address, I want them to reenter it twice (like a confirmation sorta) and if it doesn't match, then it pops up with the alert..... so the alert just applies to the one item, email address..
1/17/2006 8:40:42 PM
i'd just put everything in the one formthe alert can only pop up when the verify function is called, and since the email thing is the only thing calling it, it shouldn't be a problem
1/17/2006 9:01:39 PM
Bigman...I don't know how, but I somehow got it to work by just using the one form like you said and verifying it.THANK YOU THANK YOU THANK YOU
1/18/2006 1:40:00 PM