dontpunchme
Programmer
I am trying to validate a form.... if the form isn't valid... rather than popping an alert box.... I would like to write a line of text (document.write) an error message in the form where the error showed up.
current script:
<SCRIPT LANGUAGE="JavaScript">
<!-- //
function checkInput2(form)
{
if (form.elements['sp-q'].value == "" || form.elements['sp-q'].value == "null"
{
alert("\n Please fill in the box below.)"
;
return false;
}
else
{
return true;
}
}
// -->
</SCRIPT>
Form:
<form method="get" name="offer_form" action="#" onSubmit="return checkInput2(this)">
Name: <input size=10 name="sp-q">
</form
current script:
<SCRIPT LANGUAGE="JavaScript">
<!-- //
function checkInput2(form)
{
if (form.elements['sp-q'].value == "" || form.elements['sp-q'].value == "null"
{
alert("\n Please fill in the box below.)"
return false;
}
else
{
return true;
}
}
// -->
</SCRIPT>
Form:
<form method="get" name="offer_form" action="#" onSubmit="return checkInput2(this)">
Name: <input size=10 name="sp-q">
</form