Validation problems for mandatory field with DefaultValue
I have a fairly simple contact form with DefaultValues in Textfields because the form has no labels in the layout. The fields are also mandatory.
The problem is, that because the DefaultValues are filled into the Textfields as intended, this means that the Mandatory option does not register the fields as empty - hence it thinks they are valid when they are not.
- How do I trigger the contour validation when the fields are either empty or has the value of DefaultValue??
I have tried adding the regex ^(?!^Name$).*$ but this does not work, because then only the string "Name" is valid for this Textfield (I'm not very familiar with regex, just copy-pasted the syntax from somewhere).
Does anyone know how to solve this problem? Any alternative suggestions or methods not using regex to solve this problem are most welcome too - I just thought it would be the easiest way.
Thank you for the tip Ole. Unfortunately I could not get any entry to validate when using your snippet of regex.
I did realize though, that when adding regex to a field with a prevalue, the client-side validation kicks in as soon as the page is loaded, showing the form with validation errors.
This is not what I want, so now I'm considering an alternative solution involving background-images in stead of actual text as a "pre-value". It is not a very accessible solution, but It's the best I can come up with for now...
Validation problems for mandatory field with DefaultValue
I have a fairly simple contact form with DefaultValues in Textfields because the form has no labels in the layout. The fields are also mandatory.
The problem is, that because the DefaultValues are filled into the Textfields as intended, this means that the Mandatory option does not register the fields as empty - hence it thinks they are valid when they are not.
- How do I trigger the contour validation when the fields are either empty or has the value of DefaultValue??
I have tried adding the regex ^(?!^Name$).*$ but this does not work, because then only the string "Name" is valid for this Textfield (I'm not very familiar with regex, just copy-pasted the syntax from somewhere).
Does anyone know how to solve this problem? Any alternative suggestions or methods not using regex to solve this problem are most welcome too - I just thought it would be the easiest way.
Try
^(?!((name$)|($)))
Thank you for the tip Ole. Unfortunately I could not get any entry to validate when using your snippet of regex.
I did realize though, that when adding regex to a field with a prevalue, the client-side validation kicks in as soon as the page is loaded, showing the form with validation errors.
This is not what I want, so now I'm considering an alternative solution involving background-images in stead of actual text as a "pre-value". It is not a very accessible solution, but It's the best I can come up with for now...
I found a solution!
I simply removed the defaultvalue and just positioned the label on top of the input in stead, show/hiding it on focus/blur of field.
The result is the same for the user, more accessible because labels are used, and contour validation works without any problems :-)
is working on a reply...