B4J Question [BANanoVueMaterial] LoginDialog example Required field not validated.

khng

Member
Licensed User
Longtime User
Hi Dear @Mashiane, I am exploring the loginDialog example, Notice that the following code

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)

does not trigger the error message if I just click the SIGN IN without filling any field.

LoginDialog.png

I am using Chrome 81 with WEB Server for Chrome Extension.

What am i missing ?
 

Mashiane

Expert
Licensed User
Longtime User
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.

ensure that for both controls you have

B4X:
txtEmail.SetRequired(True)
txtPassword.SetRequired(True)
 
Upvote 0

khng

Member
Licensed User
Longtime User
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.

LoginDialog.png
 
Upvote 0

khng

Member
Licensed User
Longtime User
Yes, it has been fixed:), thanks.

LoginDialog.png

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
 
Upvote 0

khng

Member
Licensed User
Longtime User
Yes, it has been fixed:), thanks.

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
Remember, banano compiled b4x code to javascript. So you can still use either.

If you intend to do javascript validation, you can use #if ... #end if.

Sure will do...

Ok. I got it. Thanks.
 
Upvote 0
Top