1

I have on load event default values for several text fields. However, when any of the text fields is edited and made blank after it submitted the default values reappear. How do I make it that if its empty by the user that it remains empty after submission?

1
  • you said javascript: post some code so we can see what you're doing and if you're doing the right thing? Commented Jul 22, 2011 at 15:15

1 Answer 1

1

By default value, do you mean the value in the value atttribute? If so, the value attribute doesn't specify the default value, it specifies the current value period. If you don't want it to be displayed, set it to an empty string.

Alternatively, you can use the html5 placeholder attribute which will disappear when the text box gets focus.

Sign up to request clarification or add additional context in comments.

1 Comment

That's not technically true: the initial value of a form field is defined by the value attribute. The value attribute should never change, but the element's value property can. See the w3c spec on form fields.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.