Here’s an example project with a simple subclass of WebTextField called WebTextFieldValidated. It has an enumeration called States with the following values:
Unvalidated
Valid
Invalid
And a State as States property.
This and many more features are built in to GraffitiTextField, and you’d probably greatly benefit from using that if you’re doing extended validation of data or simply want a lot more functionality with less work.
That type of validation is done with the <form> element using browser validation, so you’d actually need quite a bit of work to implement the additional valid-feedback and invalid-feedback elements and have them operate the way you’d like. Or just make a WebTextFieldWithValidation container that has a label which you show/hide/style based on the state.
Required is largely useless in the Xojo context as you aren’t performing actual form submissions and using client-side validation. Any validation occurs server-side where you can report that a field is required statically in the UI or upon validating the data before conditionally carrying out whatever operation your Xojo code is meant to perform.
Event buttonSubmit.Pressed()
if fieldEmail.Text = "" then
labelInvalid.Visible = True
return
end if
doSomething()
End Event
And I have to caution against making many heavy modifications to the DOM of framework Web controls outside of the features they provide. They may be re-rendered by the framework causing all of those changes to be discarded.