SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist Pixelateur's Avatar
    Join Date
    Feb 2006
    Location
    Hamburg, Germany
    Posts
    593
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Forms don't work

    Hi,

    Please take a look at my new project. There are three forms on the site, but only the "Reservation" form works. The other two can't be processed for some reason.

    Can anybody help me out here? I've already spent an hour trying to figure out the source of the problem. Cheers.

  2. #2
    SitePoint Evangelist Pixelateur's Avatar
    Join Date
    Feb 2006
    Location
    Hamburg, Germany
    Posts
    593
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, and by the way, don't be confused, the site language is German. But you should get the idea...

  3. #3
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Pixelateur View Post
    Hi,

    Please take a look at my new project. There are three forms on the site, but only the "Reservation" form works. The other two can't be processed for some reason.

    Can anybody help me out here? I've already spent an hour trying to figure out the source of the problem. Cheers.
    It's perfectly simple - all your validation functions are returning false unconditionally, so your form submission is always suppressed.
    Tab-indentation is a crime against humanity.

  4. #4
    SitePoint Evangelist Pixelateur's Avatar
    Join Date
    Feb 2006
    Location
    Hamburg, Germany
    Posts
    593
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Logic Ali,
    Thanks for your help. Of course, you're right.
    I changed the code as follows:
    Code:
    function validate_contactform()
    {
    	valid = true;
    	var re = /[A-Za-z0-9._-]+@[^.]+\..+/;
    	if ((document.contactform.personenname.value == "") 
    	|| (document.contactform.email.value == "") 
    	|| (!re.test(document.contactform.email.value))
    	|| (document.contactform.nachricht.value == ""))
    	{
    		alert ("Sie haben wichtige Angaben vergessen...");
    	}
    	else 
    	{
    		valid = false;
    	}
    	return valid;
    }
    But now, everything is being sent, even if a validation returns false. Any message is being sent!
    My JavaScript skills are very... basic, that's probably why I don't get this... :-(

  5. #5
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Pixelateur View Post
    Hey Logic Ali,
    Thanks for your help. Of course, you're right.
    I changed the code
    But now, everything is being sent, even if a validation returns false. Any message is being sent!
    My JavaScript skills are very... basic, that's probably why I don't get this... :-(
    Code:
    function validate_contactform()
    {
     valid = true;
     var re = /[A-Za-z0-9._-]+@[^.]+\..+/;
     if ((document.contactform.personenname.value == "") 
        || (document.contactform.email.value == "") 
        || (!re.test(document.contactform.email.value))
        || (document.contactform.nachricht.value == ""))
       {
         alert ("Sie haben wichtige Angaben vergessen...");
         valid = false;
       }
     
     return valid;
    }
    Tab-indentation is a crime against humanity.

  6. #6
    SitePoint Evangelist Pixelateur's Avatar
    Join Date
    Feb 2006
    Location
    Hamburg, Germany
    Posts
    593
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow, that's it. Thanks a lot & sorry for my rookie mistake. It really wasn't my day! Cheers!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •