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:
If I don't make it follow right behind, the user puts in the whole thing,
If I default it to "blah@mail.example.org" 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 开发者_Go百科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.
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";
}
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.
精彩评论