Link to home
Start Free TrialLog in
Avatar of aeonflux2
aeonflux2

asked on

Field Validation

@If(@Length(@Trim(@Text(MSSN1))) =9; @Failure("This field must be 9 characters."; @Success)

This is for an editable text field and I keep getting "Too many arguments for @function. Any idea what I've done wrong?
SOLUTION
Avatar of marilyng
marilyng

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sjef Bosman
Sheesh... 500 points for a parenthesis...  

:-))
Avatar of aeonflux2
aeonflux2

ASKER

Which I would do, but unfortunatly, it doesn't seem to work. I can put 7 char or 20 chars and it still lets me save the form with no error message....
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Your eyes are good, man! But, on a meta-level, I'd advise to handle this differently:
- the @Trim should be in the transformation event, not in validation
- there's @ThisValue nowadays...

The code would become:
    - Transformation:
        @Trim(@ThisValue)
    - Validation:
        @If(@Length(@ThisValue) !=9; @Failure("This field must be 9 characters."); @Success)
Agree with all... Sorry, I just focused on the error message and not the quality of the validation :)

This works for greater than 9 characters:
@If(@Length(@ThisValue)>9; @Failure("This field must be less than or equal to 9 characters."); @Success)

This works for only 9 characters (as suggested by sjef and Shuboarder):
@If(@Length(@ThisValue)!=9; @Failure("This field must be 9 characters in length."); @Success)

Maybe we can turn this into a 500 point discussion?
Last thing, what should I add if I want to allow it to be 0 or 9 characters in length. I tried several permutations but they wouldn't seem to work.
What did you try?? Suggestion: use ""
@If(@Length(@Trim(@Text(MSSN1)))) !=9;""; @Failure("The Manager Social Security field on line 1 must be 9 characters"); @Success

allows any length...
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ah, I see we're busy adding a second and third question to the original question!
Thanks sjef. BTW, I enjoyed the bananna story!
Hate to be picky, but the original question was to remove the error message :)  How fast they forget!!  (sob, sob)

Guess me and Shuboarder are just chopped liver, huh?
aeonflux2,

That's not entirely fair, I agree with Marilyn. She saw the first mistake, Shu the meat-mistake and I the meta-meta-mistake. Then we discussed somewhat more about various expressions etc. The jackpot shouldn't be mine. I suggest you ask for the question to be reopened, and then split the points. As you think what's fair.
Ah, chivalry is still alive!  By the way, what was the "bananna" story?
Be quiet, damsel, and read my missive in the EE-profile...
Ah, corporate culture... forgot it was there.