My goal is to set the username to lowercase if user accidentally key in uppercase letters in angular2.
我的目标是如果用户意外地在angular2中键入大写字母,则将用户名设置为小写。
For an example, i set the user name to admin , if user key in Admin. It should recognize as "admin" rather than "Admin".
例如,如果管理员中有用户密钥,我将用户名设置为admin。它应该被识别为“管理员”而不是“管理员”。
I have tried to add .toLowerCase but it is not working correctly and i am usure how should i code it..
我试图添加.toLowerCase,但它无法正常工作,我很有用,我该怎么编码呢..
This is my original code i have and it is working, Admin must key in as "admin" inside user and it will work.
这是我的原始代码,它正在工作,管理员必须在用户内部输入“admin”,它才能正常工作。
But what i am working at is. i want to make it not key sensetive. so if admin key in as "Admin" . he is able to log in as well without modifying my code.
但我正在做的是。我想让它不是关键的感觉。所以如果admin键入“Admin”。他也可以在不修改我的代码的情况下登录。
loginCallback: (params: any)=>{
if(params.user == "admin" && params.pass == "demo") this._router.navigate(["/App/Version/3-0-0"])
else this._errorSvc.setErrorMsg("You have entered an invalid username or password.");
}
As mentioned above. I tried using this, i just simply added .toLowerCase. but when i tried to log in as "admin" or "Admin" . Nothing is working. Any help will be greatly appreciated. Thanks .
正如刚才提到的。我尝试使用它,我只是添加.toLowerCase。但当我尝试以“管理员”或“管理员”身份登录时。没有什么工作。任何帮助将不胜感激。谢谢 。
loginCallback: (params: any)=>{
if(params.user.toLowerCase == "admin" && params.pass == "demo") this._router.navigate(["/App/Version/3-0-0"])
else this._errorSvc.setErrorMsg("You have entered an invalid username or password.");
}
1 个解决方案
#1
3
You're missing parentheses after toLowerCase().
在toLowerCase()之后你缺少括号。
#1
3
You're missing parentheses after toLowerCase().
在toLowerCase()之后你缺少括号。