Hello,
I put the formula below in the field input validation event, the form includes some of subforms and LotusScript for validation.
When I put the wrong data in the field->save it, I did not got “You must enter code like k7p”) error message pop up. the document with wrong data was saved, that means validation doesn’t work. How could this happened? Is it LotusScript affect or against this formula?
@If(@Matches(@ThisValue; “{A-Za-z}{0-9}{A-Za-z}”); @Success; @Failure(“You must enter code like k7p”))
Thanks a lot.
Linda
Linda
Subject: Formula doesn’t work properly.
Hi Linda,
I used essentially the same formula you had and put it to the test (although since I am not validating, it is not sensible to use @Success and @Failure). If you copy the following into a button and test, you should see that it works as expected:
x := “”;
y := “”;
@Set(“x”; “1A1”);
@Set(“y”; @If(@Matches(x; “{A-Za-z}{0-9}{A-Za-z}”); “OK”; “No good”));
@Prompt([Ok]; “Result”; y);
@Set(“x”; “A1A”);
@Set(“y”; @If(@Matches(x; “{A-Za-z}{0-9}{A-Za-z}”); “OK”; “No good”));
@Prompt([Ok]; “Result”; y);
@Set(“x”; “1A1A”);
@Set(“y”; @If(@Matches(x; “{A-Za-z}{0-9}{A-Za-z}”); “OK”; “No good”));
@Prompt([Ok]; “Result”; y);
@Set(“x”; “A1A 2X2”);
@Set(“y”; @If(@Matches(x; “{A-Za-z}{0-9}{A-Za-z}”); “OK”; “No good”));
@Prompt([Ok]; “Result”; y)
Can you provide exactly the values you are trying to test to make it fail?
Subject: RE: Formula doesn’t work properly.
Hi Cesar, I guess my problem is the form (the application was designed by someone else, I just maintain it) includes many sub forms, for each sub form, it contains some LotusScript for validation.
So, I have to modify the LotusScript instead of using formula.
Your coding is useful, but I do want to know how to use LotusScript to write “@Set(“y”; @If(@Matches(x; “{A-Za-z}{0-9}{A-Za-z}”); “OK”; “No good”));” , then I will be able to change the coding.
I really appreciate all your help. ^-^
Linda
Subject: RE: Formula doesn’t work properly.
In LotusScript, you will have to use the LIKE operator. Also, there is no corresponding @Success / @Failure - I presume you know how your application displays a validation failure to the user (and there are many possible ways to do so) so I won’t get into that here.
If Not (doc.FieldName(0) Like “[A-Za-z][0-9][A-Za-z]”) Then
'validation failure on field named “FieldName” - notify user
End If