开发者

Form submit add domain to username field if missing

开发者 https://www.devze.com 2023-01-27 11:33 出处:网络
I have a login form that includes a username and password field. Users will be able 开发者_开发百科to login using:

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';
}
0

精彩评论

暂无评论...
验证码 换一张
取 消