Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    Bloomington, Indiana, USA
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript code snipet running multiple times

    If the user enters a valid e-mail address the first time, all is well. But if the script runs through the Validate() code multiple times, then the prompt for their name is shown multiple times. Any guidance is greatly appreciated! Attached is a portion of the code.

    Thanks,
    Kathy
    Attached Files Attached Files

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Javascript code snipet running multiple times

    Hi Kathy,

    Try adding "var" to your username line...

    var UserName = prompt("Please enter your first and last name", "");

    Do you also need to check to make sure a valid username is entered?

    If so, you'll want to have a similar validation for the Username prompt. Of course, I'm guessing the email is required and the username is just for convenience.


    I'm curious - why not just use an HTML form instead of javascript input boxes? You can still use javascript to validate the form values, but it seems a little less intrusive to the user that way... (just my 2 cents <img src=/S/2cents.gif border=0 alt=2cents width=15 height=15>) For an example, check out http://JohnstonData.com/contact.asp. Try changing the Reason for Contact to "Request Price Quote" and submit with a blank name or email... Javascript catches that and requires a name and email depending on which Reason is selected.

    Hope this helps

    (By the way - I'm in Indy. I was down to Bloomington to visit a friend last weekend. Small world!)

  3. #3
    Star Lounger
    Join Date
    Jan 2001
    Location
    Bloomington, Indiana, USA
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Javascript code snipet running multiple times

    Mark,
    You've helped me before -- how cool that you're in Indy. BTW, I like your form design!

    Adding VAR didn't keep the code from repeating. I would have thought the code below Validate(MailAddress) wouldn't fire until the variable MailAddress passed the validation routine. <sigh> And you're right, the user name is for convenience; we can actually tell who it is by the internal e-mail address.

    I'm pulling information from a database via ASP and adding JavaScript just to get the user's e-mail address. Everything else is ASP.

    Thanks!
    Kathy

  4. #4
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Javascript code snipet running multiple times

    Ahh - I see. I misunderstood from the original post.

    I'll see if I can come up with a fix to the current process.

    In the meantime, I'm sure there are a few other Loungers that are much more JavaScript savvy than myself...

  5. #5
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Javascript code snipet running multiple times

    OK - How's this (see attachment)?

    It's a little different approach, but seems to accomplish the task.

    Post back if it's not what you need... <img src=/S/smile.gif border=0 alt=smile width=15 height=15>
    Attached Files Attached Files

  6. #6
    Star Lounger
    Join Date
    Jan 2001
    Location
    Bloomington, Indiana, USA
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Javascript code snipet running multiple times

    Mark,
    Works like a charm! Thank you so very much for your help!!

    Kathy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •