How to validate default value in texfield using java Script?
sathish
2011-10-13 00:35:56 UTC
In JSP textfield i set default value for eg..(enter your name). while submitting without any changes to textfield the default value should not go, but null or empty value should go how to do this using Javascript...
Three answers:
?
2011-10-13 02:38:20 UTC
Put an "id" in your text field. (id="txtfld")
In javascript, BEFORE submitting the form, call this:
var tf = document.getElementById("txtfld");
var txt = tf.value;
if (txt == "enter your name")
{
alert ("you must fill the text area");
tf.focus();
return;
}
...
?
2011-10-13 15:12:56 UTC
Did you use the placeholder attribute instead of pre-setting the value attribute of the input element? Probably not. Do this instead:
This won't get submitted with the form.
The form will, by default, submit with null or empty values.
?
2017-02-25 09:18:27 UTC
he's 10 they're in all probability in basic terms his pals. cease reading too a lot into it, in the event that they're those form of calls why does your son furnish out your extensive form and image it extremely is okay? Take some duty and get ready the boy some morals extremely of coming to Yahoo speaking nonsense, how previous are you? 15? performing like a toddler.
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.