Issue with spry validation from a dynamically updated input field vai javascript

834 Views Asked by At

I have a form on my website that uses spry validation widgets. I have recently added a date feature that uses 3 drop down boxes (day, month, year). I've used the onchange feature of the selection boxes to update a text field with the date and used spry validation on that input box to make sure its a valid date.

The JavaScript update function works but the spry does not consider the input text field changed. If I manually input the same date in the same format into the field the validation works, it's just when the field is changed dynamically via JavaScript that it does not work.

Any ideas why this is happening and how to fix it?

2

There are 2 best solutions below

0
On

I figured it out. When I finish updating the input field via javascript I needed to add this line of text to trigger the spry validation.

spryNameofSpry.validate();

Hope this helps someone someday.

0
On

Here's what worked for me:

Say you have sprytextfield1 as the variable for your validation text field. Then use

sprytextfield1.removeHint()
sprytextfield1.setValue('your value goes here')
sprytextfield1.validate()