0

I am working with appcelerator and i am creating a login window. But all the validations do not seem to work properly. Also the error i am facing for the validation where username should not be numeric is throwing me a runtime error. Please help!

function loginUser() {
    var uName = $.username;
    var pwd = $.password;
    var correctUName = "sayali";
    var correctPwd = "123sayali";
    var letters = /^[A-Za-z]+$/; 

    if(uName == "" || pwd == ""){
        alert("Please fill all the credentials!!");
      } 
    else{
        if(uName.match == letters){
            if(uName == correctUName){
                if(pwd == correctPwd){
                    alert("Login Successful!!");
                }
                else{
                    alert("Incorrect Password!");
                }
            }
            else{
                alert("User doesn't exist!");
            }
        }
        else{
            ("Numeric values are not allowed in Username!");
        }
    }
}
SylieC
  • 67
  • 6

1 Answers1

0

Instead of using uName.match == letters you should use i.e. letters.test(uName)

Click here for more information on regular expressions and Javascript