Hi Everyone,
We utilize a custom Employee Number + PIN validation for several different sign offs, and we need to incorporate this into our Nintex Forms.
We were successful in creating the custom control that is one single control with two fields by default: one field for the Employee Number and one for the PIN (picture of this attached). Our main problem is figuring out how to validate this control (using our web service) and display a custom error message to our users.
We need to do this on the server side code and not with javascript or inline/runtime fuctions in order to avoid the possibility of using developer tools to get around the validation and submit the form without proper authentication of the PIN.
Here is what we have done so far:
The crux of the issue is just getting the submission to stop and providing the proper error message. The two textboxes don’t have any impact on this either.
Any help is much appreciated! Thank you.
Hi Amy Thompson!
I just figured out how to achieve this: you have to insert a CustomValidator control in addition to your textbox(es), and implement the ServerValidate event.
Something like this:
protected override void CreateFormControls()
{
TaxNumberTextBox = new TextBox();
TaxNumberTextBox.ID = "TaxNumberTextBox";
TaxNumberTextBox.Text = String.Empty;
this.Controls.Add(TaxNumberTextBox);
TaxNumberValidator = new CustomValidator();
TaxNumberValidator.ControlToValidate = TaxNumberTextBox.ID;
TaxNumberValidator.ServerValidate += Validator_ServerValidate;
TaxNumberValidator.ErrorMessage = this.ControlSpecificProperties.ValidationErrorMessage;
TaxNumberValidator.Display = ValidatorDisplay.None;
TaxNumberValidator.ValidationGroup = this.FormValidationGroup;
this.Controls.Add(TaxNumberValidator);
}
void Validator_ServerValidate(object source, ServerValidateEventArgs args)
{
args.IsValid = args.Value != "1"; // logic should be implemented here
}
Hope it helps.
Cheers,
Daniel