Aside: Are you only doing client validation? You really, really should
be doing server validation and adding the javascript as sprinkles on
top.

- Gabriel

On Fri, Mar 26, 2010 at 11:53 AM, Orlini, Robert <rorl...@hwwilson.com> wrote:
>
> Sorry folks a little off topic here, but I'm not good at javascript.
>
> I have this email confirm code that tells me I need to enter a valid email, 
> but then still sends me to the next form which generates an error because of 
> no email address.
>
> The problem seems to be in this section not stopping the submission so that 
> the user can enter a valid email
>
> ---------------------------
> if (goodEmail){
>   good = true
> } else {
>   alert('Please enter a valid e-mail address.')
>   field.focus()
>   field.select()
>   good = false
>      }
> }
> ---------------------------
>
> Any help appreciated.
>
> RO
> HWW
>
> The full code is below:
>
> var good;
> function checkEmailAddress(field) {
>
> // Note: The next expression must be all on one line...
> //       allow no spaces, linefeeds, or carriage returns!
> var goodEmail = 
> field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
>
> if (goodEmail){
>   good = true
> } else {
>   alert('Please enter a valid e-mail address.')
>   field.focus()
>   field.select()
>   good = false
>      }
> }
>
> function sendOff(){
>
>   checkEmailAddress(document.TheForm.email)
>   if ((document.TheForm.email.value ==
>        document.TheForm.email2.value)&&(good)){
>      // This is where you put your action
>      // if name and email addresses are good.
>      // We show an alert box, here; but you can
>      window.location= 'http://192.29.16.25/oclc/forms/oclc_3.cfm'
>      // to call a subsequent html page,
>      // or a Perl script, etc.
>     // alert("Name and email address fields verified good.")
>   }
>   if ((document.TheForm.email.value !=
>          document.TheForm.email2.value)&&(good)){
>          alert('Both e-mail address entries must match.')
>   }
> }
> </script>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332317
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to