I am not sure exactly how to use a "customValidation", I defined the function (along with a console.log statement to ensure it was arriving into the function), and then passed in into the form, but I dont seem to be calling the function as expected?
function validate(field) {
console.log('validating',field);
let error = false;
let errorMsg = '';
if (field.name === 'username' && !(field.value && field.value.trim())) {
error = true;
errorMsg = 'Username is required';
}
if (field.name === 'password' && !(field.value && field.value.trim())) {
error = true;
errorMsg = 'Password is required';
}
return { error, errorMsg };
}
I am not sure exactly how to use a "customValidation", I defined the function (along with a console.log statement to ensure it was arriving into the function), and then passed in into the form, but I dont seem to be calling the function as expected?