Taking this product page as an example:

I'd like my text inputs (door number and street name, in the case of the example above) to fail validation if left with their default values.

I see two possible methodologies here, but I'm unsure as to which would be the better option, or how I would go about implementing either of them.

One possible approach I see would be to store the initial (default) input values after page load, and then compare the input values when 'add to cart' is clicked against the stored initial values, failing validation if they match.

The other approach I envision working would be to create a static blacklist of default input values, and when 'add to cart' is clicked, test the current input values against those in the blacklist, failing validation if matches are found.

Which would be the best approach to take and how might I go about applying it?

  • set default value in input field that match the validation Commented Nov 9, 2016 at 11:49

1 Answer 1


Instead of value attribute use the placeholder attribute

<input type="text" name="test" placeholder="First name">


  • Perfect, thanks a million. I like it when the answer is simpler than expected. Will accept your answer once the timer is up. Commented Nov 9, 2016 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.