Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2005
    Location
    France, Bordeaux
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    prompt(): how to differenciate cancel and empty input?

    return value of window.prompt() seems to be an empty string instead of something like false.

    My question is simple, how to make the difference between the cancel push and the empty input?

    thanks for any help!

  • #2
    Regular Coder
    Join Date
    Nov 2004
    Location
    The land of chocolate
    Posts
    226
    Thanks
    1
    Thanked 16 Times in 16 Posts
    If I recall correctly, in IE window.prompt() returns null when the cancel button is pressed, and an empty string when no text is entered. So differentiating should be no problem there.

    I don't know about other browsers though, it is indeed possible that they return an empty string also when the cancel button is pressed.
    -Snow

    Susie, if you want to see your doll again, leave $100 in this envelope by the tree out front. Do NOT call the police. You CANNOT trace us. You CANNOT find us.

    Sincerely,
    - Calvin.

  • #3
    New Coder
    Join Date
    Mar 2005
    Location
    France, Bordeaux
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Apparently not the cas for Gecko based

    Unfortunately Firefox has the empty string behaviour...
    So I won't use it


  •  

    Posting Permissions

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