I have one fields displayed 10 times by a repeat control.
when I enable field validation for this field all 10 fields must be filled in which is not what I want.
How can I make the field validation to only work on the first fields (or second)
thanks
Thomas
Subject: rowIndex
I haven’t tried this out and I’m assuming it’s a standard edit box (not multi-line), but this is how I would imagine you could get this working:
The repeat panel should have an Index name field. Give it a variable name (i.e. rowIndex).
Then on your field you want validation for, hit the compute diamond next to required field, so you can add some JavaScript.
This part will determine when the field is required and when it is not. For instance if you only want the field to be required on the first row and not on the other 9, you could do this:-
if (rowIndex == 0){
return true;
}else{
return false;
}
N.B. The index always starts from 0
I am using 8.5 at the moment and there is one major downside however to computing required fields. I’m not sure if this is fixed in 8.5.1 (maybe you can let me know if it is?).
If you add a custom error message to a field (i.e. ‘this field is required’), the computed requirement is ignored, and the field just becomes a normal required field. In other words it will put you back to square 1 where the field is required no matter what (in your case all 10 fields become required again). If you DON’T have a custom message, the computed code will run and work, however you get a not-so user friendly error message ‘Validation Error: Value is required.’
Hope that helps