0

I might just be using the wrong keywords on Google, but what I have in mind is:

 --------------------------------
|    What is your mailbox?       |
|                                |
|    [       ]@mail.example.org  |
|                                |
|        [OK]      [Cancel]      |
 --------------------------------

The idea being that the input field is followed right behind by the mail server name, to help avoid instances where:

  1. If I don't make it follow right behind, the user puts in the whole thing,

  2. If I default it to "[email protected]" they delete the server name.

In either case, it's not too big a deal, as I will know that if the returned value does have the server, to remove it and if doesn't, I know what server it belongs to, but I think this visual aid will be a better user experience and lower the amount of validation worries I tend to get.

6
  • 'native' prompt doesn't allow this. Instead you can show a div with form on top of page, and I'd rather use jquery than invent a bicycle Commented Apr 7, 2010 at 0:49
  • @vittore I'd rather use the native prompt rather than hit it with a tank. jQuery + jqUI = tons of code Commented Apr 7, 2010 at 0:52
  • 1
    normally, i don't think of jquery/jqui as that taxing, or at the very least, it pays for itself, but in this case, I'm trying to make an iphone-driven page (it's not exclusive just to be, before you ask, it's for downloading mobile profiles). I would (and might) just say screw it and use the jq-ui, but I actually like the prompt/alerts style native to the mobile safari, so I was hoping my goal was possible to keep that native feel. Commented Apr 7, 2010 at 0:59
  • @nickf: i always try not to do any preoptimization. If tons of code is a problem - start optimizing it and write your own UI controls. If you hold small site with not that big auditory - using jqUI is not that big deal Commented Apr 7, 2010 at 2:44
  • @Anthony: have you seen this also iphone.hohli.com/#? Commented Apr 7, 2010 at 2:46

2 Answers 2

1

If the user deletes the host and doesn't specify their own host, you can assume that they intended the default host.

var email = prompt("What is your email address?", "@mail.example.org");
if (email.indexOf("@") === -1) {
  email += "@mail.example.org";
}
Sign up to request clarification or add additional context in comments.

Comments

0

You can set a default value in the standard Javascript prompts, but you can't do much more than that. I would just check afterwards and strip or add the server part as needed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.