6

I need an 8 characters length enforcing validator. I created a MaxLength=8 and combined it with a MinLength=8 validation rule.

Then I enter "1234567890123' and it's saving, no question asked!

It does work if I click the "REVIEW" tab then "Validation". At the very bottom of a long list of schema warnings for each and every field. Our users won't do that.

I've been researching quite a bit already. One talk about "Quick Action Bar" that I don't see anywhere, and so on. I just need a simple, text field validation like exist in any html form. You enter data wrong, it displays a message and you can't save. Period. How do you do that?

Thanks in advance!

2 Answers 2

4

you missed to add Parameters on your validator

enter image description here

Parameters are applied using a QueryString-like list like this:

[parameter]=[value]&[parameter]=[value]

The “Result” paremeter determines the default result value of a validation.

Possible values are:

Valid = Green, everything is fine

Suggestion = Bright Orange, hmm, take a look at this

Warning = Orange, you should do something about this

Error = Red, this is an error you know

CriticalError = Red, user is warned before saving

FatalError = Red, user cannot save item before validator is cleared

More informations you can find here.

1
  • Thanks a bunch! I think I was using CriticalError, and/or possibly didn't Save after adding the "Result" parameter. Also it takes a bit of trial and error to choose the right of the 4 "Quick Action Bar", "Validate Button", "Validator bar", and "Workflow" that'll be responsive to the "Save" button. I found out that it was #3, "Validator bar" without really knowing how/why but that's OK! One thing I'm still not able to get, is the Text= parameter like the Sample SSN has: Pattern=^[0-9]{8}$**&Text=**Field "{0}" needs to be an 8 digit value. Example: 01065743&Result=FatalError Jul 13, 2017 at 18:16
3

As well as using a rules engine based validator, there are also validation fields on the Field template that you can use:

Field template validation fields

The Validation field takes a regex and the ValidationText field can be used for the warning text. Using the following regex:

/^.{8,}$/

That makes sure that the content has a minimum length of 8 characters. Now when the content editor tries to save an item that fails that validation, the message will be shown and the user cannot save the item:

Validation failed

This can be a simpler setup than rules based validation, although it is limited to what you can do with a single regex statement.

1
  • 1
    Thanks a plenty! I had missed this simpler way completely, online material is somewhat more focused on the other, more complex but reusable way. I've removed the '/' and made it digit only like so: ^[0-9]{8}$ Jul 13, 2017 at 18:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.