Last active
December 25, 2015 01:29
-
-
Save PetersonDave/6895451 to your computer and use it in GitHub Desktop.
Example of how to access a field on a WFFM form outside the validator's field context.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override bool OnServerValidate(string value) | |
{ | |
// get the form | |
var form = WebUtil.GetParent<SimpleForm>(this); | |
// find another field within our form | |
var field = (SingleLineText)WebUtil.FindFirstOrDefault(form, c => c is SingleLineText && (c as SingleLineText).Result.FieldName == "City"); | |
// compare values between this field (State) and the value of a different field (City) | |
bool isBoston = field != null && field.Result.Value.ToString() == "Boston"; | |
bool isMassachusetts = !string.IsNullOrEmpty(value) && value == "MA"; | |
return isBoston && isMassachusetts; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment