Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Help with restoring focus to failed date validation in date/time field

Avatar

Level 1

I am rather new to creating forms.  I have added a date/time field and made it user entry required.  I am also requiring the data validation as mm/dd/yyyy.  Ihave tested and if the user enters in an incorrect format the error message will display.  however once they click off that message the focus is on the next field in the tab order.  I would like it to return to the date/time field.  How can I make that happen?

5 Replies

Avatar

Level 10

You can try using the following..

xfa.host.setFocus("<Date Field Name>");

Replace <Date Field Name> with the field name.. Place the above code in the event where you placed the validation code. Language needs to be Java Script..

Thanks

Srini

Avatar

Level 1

do I go into the XML source and add that in the <validate> section?

Avatar

Level 10

Not in the XML Source directly...

But if you know where you have placed the code for the date validation.. Usually in the exit event of the Date control..

Place the line of code I mentioned in the same place as your date validation..

Thanks

Srini

Avatar

Level 1

I have attempted to add the statement you provided in several events and none have worked.  I must be missing something

topmostSubform.Page1.PtDOB::initialize - (JavaScript, client)

topmostSubform.Page1.PtDOB::enter - (JavaScript, client)

topmostSubform.Page1.PtDOB::exit - (JavaScript, client)

topmostSubform.Page1.PtDOB::calculate - (JavaScript, client)

topmostSubform.Page1.PtDOB::validate - (JavaScript, client)

topmostSubform.Page1.PtDOB::mouseEnter - (JavaScript, client)

topmostSubform.Page1.PtDOB::mouseExit - (JavaScript, client)

topmostSubform.Page1.PtDOB::change - (JavaScript, client)

topmostSubform.Page1.PtDOB::full - (JavaScript, client)

Avatar

Level 10

Can you send your form to LiveCycle9@gmail.com so I can have a look at it..

Please mention which field you have the issue with..

Thanks

Srini