When I set up form validation using a dataset connected submit button, the subsequent form validation doesn’t work properly. I am able to click through my form without being prevented by form validation.
Note that if I edit any field on the form in any way, the validation will then work.
The issue can be seen in the video below.
Details:
The form in question contains a single dataset and 8 input fields, including 5 text boxes, one radio button group and 2 check boxes. Each input field is connected to a dataset field and there is one button on the page connected to the dataset submit functionality.
When I first come to the page, all my required fields are red (note, this is undesirable since I would prefer they not go red until the submit button is clicked, but I can live with it). If I click the submit button without editing any fields, I am NOT prevented from going to the next page.
If I am in the same scenario described above and edit any field on the form (even one that isn’t required), if I then click the submit button I am prevented from going to the next page and given the appropriate validation failure message.
Have I set something up incorrectly?
UPDATE:
I’ve discovered a hack to work around this, and while it isn’t my favorite, it has resolved the issue for now:
$w.onReady(function () {
$w('#camperRegistrationDataset').onReady(() => {
var guardianName = $w('#guardianName').value;
$w('#camperRegistration2019Dataset').setFieldValue('guardianName', guardianName);
});
});
By setting a field to its own existing value, the validation is able to recognize that it has failed.