Jump to content


form check js not working


2 replies to this topic

#1 tiki

    Young Padawan

  • Members
  • Pip
  • 259 posts
  • Gender:Male
  • Location:California

Posted 20 March 2006 - 12:15 AM

Its not working and submits the data.

function checkComment() {
	var msg = "";

	if ((document.forms['comment'].name.value=='') || (document.forms['comment'].name.value=='Name'))
		msg += "Enter a name\n";
			
	if ((document.forms['comment'].message.value=='') || (document.forms['comment'].message.value=='Message'))
		msg += "Enter a message\n";

	if (msg == '') {
		return true;
	} else {
		popup = "Please fix the following errors:\n\n" + msg;
		alert(popup);
		return false;
	}
}


#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 20 March 2006 - 06:24 PM

Can you show us the form delcaration tag (the opening <form> tag and it's attributes)? You need to make sure you have an onSubmit attribute that would look something like: onSubmit="return checkComment();"

#3 tiki

    Young Padawan

  • Members
  • Pip
  • 259 posts
  • Gender:Male
  • Location:California

Posted 21 March 2006 - 02:04 AM

It has that, but I instead switched to php checking, so never mind this!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users