private bool CheckFields() { string mail = mailField.text; string pass = passField.text; bool isMailEmpty = string.IsNullOrEmpty(mail); bool isPassEmpty = string.IsNullOrEmpty(pass); bool isMailValid = mail.Contains("@") && mail.Contains("."); bool isPassShort = (pass.Length < passwordMinLength); if (isMailEmpty) { mailField.SetErrorState(emptyEmailMessage); return(false); } else if (!isMailValid) { mailField.SetErrorState(invalidEmailMessage); return(false); } else { mailField.SetSuccessState(); if (selectedField == mailField) { selectedField.Unselect(); selectedField = null; } } if (isPassEmpty) { passField.SetErrorState(emptyPasswordMessage); return(false); } else if (isPassShort) { passField.SetErrorState(shortPasswordErrorMessage); return(false); } else { passField.SetSuccessState(); if (selectedField == passField) { selectedField.Unselect(); selectedField = null; } } return(true); }
private void HandleSelect(VRAuthInputField clicked) { selectedField = clicked; foreach (VRAuthInputField field in fields) { if (!field.Equals(selectedField)) { field.Unselect(); } } selectedField.Select(); if (SelectEvent != null) { SelectEvent.Invoke(); } }
// Use this for initialization void Start() { mailField = transform.Find("MailBlock").GetComponent <VRAuthInputField>(); passField = transform.Find("PasswordBlock").GetComponent <VRAuthInputField>(); passField.IsSecure = securePassword; fields = new VRAuthInputField[] { mailField, passField }; for (int i = 0; i < fields.Length; i++) { fields[i].OnInputFieldSelect += HandleSelect; } loginButton = transform.Find("LoginButton").GetComponent <Button>(); registerButton = transform.Find("RegButton").GetComponent <Button>(); loginButton.onClick.AddListener(onLoginHandler); registerButton.onClick.AddListener(onRegisterHandler); }