Clearing a validator


I am adding a custom validator that triggers on an on-change event however I need to be able to remove/clear the custom validator based on a field value

// Function to show referral table if happy to refer equals yes
function showReferral () {
	var referralHappy = fd.field('Would_x0020_you_x0020_be_x0020_h0').value;
	if (referralHappy == 'Yes') {
        	name: 'SPDataTable validator',
     		error: 'Error message',
      		validate: function() {
        		if (fd.control("SPDataTable1").widget.dataItems().length == 0) {
            		this.error = "Add at least one record to the table";
            		return false;
        		return true;
	} else {

My code above adds a custom validator I need to be able to remove/clear this in the else.


Hello @WRSIT,

You can clear the validation by setting its length to 0. Please see the code below.

fd.validators.length = 0;
1 Like