Hi,
I would like the button to be active by default if no date is selected or if a date equal to or after today is selected. And at the same time, the button is disabled if an invalid date or date older than today is entered.
The problem is that I can't differentiate when the user enters a wrong date and when they leave the field empty.
a!localVariables( local!dueDateAux, { a!dateField( label: "Due Date", value: ri!dueDate, saveInto: { ri!dueDate, a!save(local!dueDateAux, today()) }, validations: if( ri!dueDate >= today(), {}, "Incorrect date format or date before current date" ) ), a!buttonLayout( primaryButtons: { a!buttonWidget( label: "Submit", disabled: ri!dueDate < today(), submit: true ) } ) } )
Discussion posts and replies are publicly visible
Hello Carlos de Vega
a simple null check before evaluating your disable condition would suffice your requirement.
But I would say keeping it disabled when it is blank also is a good option, unless you want to accept a null value.
a!buttonWidget( label: "Submit", disabled: if( a!isNullOrEmpty(ri!dueDate), {}, ri!dueDate < today() ), submit: true )
a!buttonWidget( label: "Submit", disabled: and( a!isNotNullOrEmpty(ri!dueDate), ri!dueDate < today() ), submit: true() )