jeudi 15 juillet 2021

JSP/HTML5 Input Validation pattern from Properties?

i use html5 Input Fields. If i try to use pattern to Validation, i do this on this way:

<input type="text" value="${someBean.someValue}" name="someValue" maxlength="255" pattern="[A-Za-z ]{1,255}"/>

now i have some question: 1: Can u read the pattern Attribute from backingBean or a properties file? because i have a lot of input fields, and dont want so set the same Pattern for multiple input Fields. So better read the Pattern from a File or Backing. Then i can just fill it like: pattern="${someBean.somePattern}" or just from file..

2: if 1 not possible, is there a good way to set the pattern in the JSP file and set it from there to a backing bean? Because now i have to set the Pattern on every input-field and also set the same Pattern to the backing bean for Server-site Validation. This is bad, because if i want to change the pattern, i have to change every field and the backing.. (Sorry for my bad englisch)

Aucun commentaire:

Enregistrer un commentaire