views:

34

answers:

2

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.

A: 

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.

nickf
+1  A: 

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";
}
Eli Grey