I have one content type called Address. It has title, body, etc.. fields. Initially Created view for Address.
Later client wants to add search field for this view. So created exposed filter block for body field.
Now search block with results working fine.
But challenge is, we need MINLENGTH
validation to that search field.
Added $form['#validate'][] = _custom_validate;
in form_alter
.
if ($my_field_length < 4) {
form_set_error('my_field', t('Please enter minimum 3 characters.'));
}
- First Question: This validation is happening on each page load but it is not triggering when we submit form (This is ajax form).
- Second question: Is that any possible to stop validation or auto submit on intial page load?