Forum Moderators: open
I have a registration form and want to validate certain fields. I only care if the user has entered some text or not. Nothing too complicated. I have included this javascript in the head of the document:
<script language="JavaScript">
<!-- hide JS code
function isBlank(testStr)
{
if (testStr.length == 0) // nothing entered?
return true
for (var i = 0; i <= testStr.length-1; i++) // all spaces?
if (testStr.charAt(i)!= " ")
return false
return true
}
function checkForm(form)
{
if (isBlank(form.name.value))
{
alert("Please enter your name.")
form.name.focus()
return false
}
if (isBlank(form.phone.value))
{
alert("Please your phone number.")
form.phone.focus()
return false
}
if (isBlank(form.email.value))
{
alert("Please enter your email address.")
form.email.focus()
return false
}
return true
}
// end JS hide -->
</script>
When I go to view the page's source code through the browser, this javascript is missing. The page does not do any validation. What big "duh" mistake am I making?
Sincerely,
Patricia
Thank you so much for replying!
(I can't find the emoticon with a dunce cap, but that would be appropriate here...)