SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Guru tombempty's Avatar
    Join Date
    Oct 2001
    Location
    New York
    Posts
    688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Form not validating...

    Hello All:

    I have a form that I need to validate, however my site is all php with includes and I was not sure if the form would work with the onSubmit="return Check();" in the form when the page has a include to top.php

    Meaning the part that needs to go into the head part is not on that page but in an include. Does that matter or should I be doing something different to make this work?

    Thanks for any help or advice on this,

    Paul
    ********
    Regards,

    P

  2. #2
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP is parsed before Javascript even hits the browser. That said, it won't be an issue as long as the actual returned HTML (as processed by PHP) contains the javascript.

  3. #3
    SitePoint Guru tombempty's Avatar
    Join Date
    Oct 2001
    Location
    New York
    Posts
    688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh ok,

    Well, I am having trouble with this validator that is not validating. When I hit submit it just passes the information without checking the form.

    and I stripped it down to just check one field so I could see where the problems is.

    Can someone advise as to what I might be doing wrong here?

    <script language="javascript">
    function Check() {


    if (document.form1.First_Name.value == "") {
    alert("Please Enter Your First Name");
    return false;
    }
    return true;
    }

    </script>

    Then the form is:

    <form name="got_bounce_form" action="<?php echo $_SERVER["PHP_SELF"];?>" method="post" onSubmit="return Check();">

    Does anything in that look off to anyone?

    Thanks for any help or advice,

    PM
    ********
    Regards,

    P

  4. #4
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your form name is got_bounce_form but you're looking for document.form1 in the javascript. You'll want to change that to document.got_bounce_form instead and it should work.

  5. #5
    SitePoint Guru tombempty's Avatar
    Join Date
    Oct 2001
    Location
    New York
    Posts
    688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah thanks Chris,

    I just changed that on the form but it is still not working.

    Here is the link - http://dancewithcda.com/got_bounce_form2.php
    ********
    Regards,

    P

  6. #6
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Probably due to this little line here:

    Code javascript:
    if (document.got_bounce_form.Child_First_Name.value == "" || == NULL)

    That || == NULL part doesn't need to be in there, == "" will work just fine. See if that works.

  7. #7
    SitePoint Guru tombempty's Avatar
    Join Date
    Oct 2001
    Location
    New York
    Posts
    688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope.... Nothing.

    Is it possible due to a pop up JS I have on the same page, or that would not make a difference?
    ********
    Regards,

    P

  8. #8
    SitePoint Guru tombempty's Avatar
    Join Date
    Oct 2001
    Location
    New York
    Posts
    688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK nevermind,

    I found it. There was something in the pop up because I had onsubmit check() and I also had that as the name to check the form. So I just changed the name to CheckForm and now it works.

    lol, sheesh, how retarded. LOL

    Thanks for your help with this chris..

    PM
    ********
    Regards,

    P

  9. #9
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tombempty View Post
    OK nevermind,

    I found it. There was something in the pop up because I had onsubmit check() and I also had that as the name to check the form. So I just changed the name to CheckForm and now it works.

    lol, sheesh, how retarded. LOL

    Thanks for your help with this chris..

    PM
    Happens to the best of us, seriously Missing semicolons, typo'ed variables, programming languages were created for Advil marketing


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
  •