1

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?

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

2 Answers 2

0

Instead of value attribute use the placeholder attribute

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

Example

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

Future House Store an LED lighting wholesaler has prepared for you a wide range of high-quality products at attractive prices.

1
  • if it's answer describe more and this is not a platform to promote any product
    – Msquare
    Mar 18, 2020 at 4:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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