Full validation is not implemented yet in BVM and thus no notifications will be shown. A temporal implementation currently is this as per your example.
B4X:
Sub btnOkSignIn_click(e As BANanoEvent)
'get the contents of the form
Dim rec As Map = mdlSignIn.Container.GetData
'validate the details
Dim bValid As Boolean = mdlSignIn.Container.Validate(rec)
If bValid = False Then Return
vm.ShowSnackBar(BANano.tojson(rec))
'process further
End Sub
The validate method is supposed to check if values are entered and if not exists the sub.
Hi @Mashiane, I followed your advice to set required for both controls
B4X:
Dim txtEmail As VMTextField = vm.NewEmail(Me, True, "txtemail", "email", "Email Address","", True, "email", "Enter email address here", "The email address is required!", 0)
Dim txtPassword As VMTextField = vm.NewPassword(Me, True, "txtpassword", "password", "Password","", True, True, "lock", 10, "Enter password here", "The password is required!", 0)
txtEmail.SetRequired(True)
txtPassword.SetRequired(True)
And I add code to show bValid value
B4X:
Sub btnOkSignIn_click(e As BANanoEvent)
'get the contents of the form
Dim rec As Map = mdlSignIn.Container.GetData
'validate the details
Dim bValid As Boolean = mdlSignIn.Container.Validate(rec)
If bValid = False Then Return
vm.ShowSnackBar(BANano.tojson(rec) & [B]" bValid: " & BANano.ToString(bValid)[/B])
'process further
End Sub
I still cannot get the controls validated as bValid is always True.
For email validation, since full validation is not implemented yet in BVM, could you give me some directions?
Should the validation code be in B4J or javascript and called from B4J ?
BTW, I think the new version should be 3.8 instead of 3.08, last version is 3.7
For email validation, since full validation is not implemented yet in BVM, could you give me some directions?
Should the validation code be in B4J or javascript and called from B4J ?
BTW, I think the new version should be 3.8 instead of 3.08, last version is 3.7