Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Karina 6 posts 26 karma points
    Nov 17, 2010 @ 13:33
    Karina
    0

    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.

  • Ole Thorsager 5 posts 25 karma points
    Nov 19, 2010 @ 16:41
    Ole Thorsager
    0

    Try

    ^(?!((name$)|($)))

  • Karina 6 posts 26 karma points
    Nov 24, 2010 @ 09:57
    Karina
    0

    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...

  • Karina 6 posts 26 karma points
    Nov 24, 2010 @ 11:36
    Karina
    0

    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 :-)

Please Sign in or register to post replies

Write your reply to:

Draft