Form submit add domain to username field if missing
I have a login form that includes a username and password field.
Users will be able 开发者_开发百科to login using:
Domain\username And Username@domain.org.uk
However many users attempt to login using just 'username'
I want to help users by adding domain\ or @domain.org.uk to there username when they enter just 'username', when they click the login button I want to add the domain part of the username.
How can I do this in pure JavaScript?
function insertDomain (){
var txtBox = document.getElementById('Your_Textbox');
if(txtBox.value.indexOf("@") == -1)
{
txtBox.value += "@domain.org.uk";
}
}
On Submit: http://alexking.org/blog/2003/10/01/javascript-onsubmit-handler
Something along the lines of
var username = document.getElementById('username')
if(username.indexOf('@') < 0){
username = usename + '@domain.org.uk';
}
精彩评论