Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Jun 2009
    Posts
    68
    Thanks
    22
    Thanked 0 Times in 0 Posts

    Black fields in form?

    Hello

    Can anyone tell me why this form can be submitted without filling in any fields?

    PHP Code:
    <?php
        $sent 
    "false";
    if(isset(
    $_POST['ispost']))
    {
        require_once(
    "contact_form/class.phpmailer.php");

        
    $email 
        
    '
        <table width="100%" border="0">
        <tr><td style="width:100px; text-align:right">First Name:</td><td> '
    .$_POST['fname'].'</td></tr>
        <tr><td style="width:100px; text-align:right">Last Name:</td><td> '
    .$_POST['lname'].'</td></tr>
        <tr><td style="width:100px; text-align:right">Email:</td><td> '
    .$_POST['email'].'</td></tr>
        <tr><td style="width:100px; text-align:right">Phone Number:</td><td> '
    .$_POST['phone'].'</td></tr>
        <tr><td style="width:100px; text-align:right">Mobile Number:</td><td> '
    .$_POST['mobile'].'</td></tr>
        <tr><td style="width:100px; text-align:right">Postal Address:</td><td> '
    .$_POST['address'].'</td></tr>
        <tr><td style="width:100px; text-align:right">Event Date:</td><td> '
    .$_POST['date'].'</td></tr>
        <tr><td style="width:100px; text-align:right">Start Time:</td><td> '
    .$_POST['starttime'].'</td></tr>
        <tr><td style="width:100px; text-align:right">Finish Time:</td><td> '
    .$_POST['finishtime'].'</td></tr>
        <tr><td style="width:100px; text-align:right">Occasion:</td><td> '
    .$_POST['occasion'].'</td></tr>
        <tr><td style="width:100px; text-align:right">Venue Name:</td><td> '
    .$_POST['venuename'].'</td></tr>
        <tr><td style="width:100px; text-align:right">Venue Postcode:</td><td> '
    .$_POST['venuepostcode'].'</td></tr>
        <tr><td style="width:100px; text-align:right">Info Required:</td><td> '
    .$_POST['inforequired'].'</td></tr>
        <tr><td style="width:100px; text-align:right">Advert Source:</td><td> '
    .$_POST['advertsource'].'</td></tr>
        </table>
        '
    ;

        
    $bodytext PreparaMsg($email);
        
    $mailer = new PHPMailer();
        
    $mailer->AddAddress("xxx@xxx.com" ,"Your Name Here");
        
    $mailer->From      $_POST['email'];
        
    $mailer->FromName  $_POST['fname'] . " " .$_POST['lname'];
        
    $mailer->Subject   'Enquiry Form';
        
    $mailer->Body      $bodytext;
        
    $mailer->IsHTML(true);
        if(
    $mailer->Send()) 
            
    $sent "true" ;
        else
            
    var_dump($mailer->ErrorInfo);
        
        
    $bodytext "Thanks for contacting us!<br><br>This is an automatic reply to let you know that we have received your message and will be calling you back in the next 24 hours.<br><br>Kind Regards<br>Your Name Here";
        
    $mailer = new PHPMailer();
        
    $mailer->AddAddress$_POST['email'] ,"Your Name Here");
        
    $mailer->From      'xxx@xxx.com';
        
    $mailer->FromName  'Your Name Here';
        
    $mailer->Subject   'Enquiry Form';
        
    $mailer->Body      $bodytext;
    //    $file_to_attach = 'contact_form/Document.pdf';
    //    $mailer->AddAttachment( $file_to_attach , 'Document.pdf' );
        
    $mailer->IsHTML(true);
        
    $mailer->Send();
    }

    function 
    PreparaMsg($pMsg)
    {
      
    $wMsg "" ;
      for (
    $i $i strlen($pMsg) ; $i++ )
      {
       if ( 
    substr($pMsg,$i,1) == "\x0D" )
       {
        if ( (
    $i 1) && (substr($pMsg,$i-1,1) != "\x0D") )
         
    $wMsg $wMsg."<br>" ;
       }
       else
        
    $wMsg $wMsg.substr($pMsg,$i,1) ;
       }
      return 
    $wMsg ;
    }
    ?>

    <script src="contact_form/jquery-validate.min.js" > </script>

    <script type="text/javascript">
    $(document).ready(function(){
        $("#contact").validate({
            invalid:function(){alert("Please Input all fields");}
            });
        

      });
    </script>

    <h2 style="color:green"> <?=($sent=="true"?"Thanks!  We'll call you back in the next 24 hours.":"")?></h2>

    <div class="iform">
    <form id="contact"  method="post" action=""  >

    <div class="label">First Name</div>
    <div class="question"><input class="input" type="text" data-required id="fname" name="fname" placeholder="First Name"  /></div>
    <div class="clearleft"></div>

    <div class="label">Last Name</div>
    <div class="question"><input class="input" type="text"  data-required id="lname" name="lname" placeholder="Last Name"  /></div>
    <div class="clearleft"></div>

    <div class="label">Email Address</div>
    <div class="question"><input class="input" type="email" data-required id="email" name="email" placeholder="Email Address"  /></div>
    <div class="clearleft"></div>

    <div class="label">Telephone Number (home)</div>
    <div class="question"><input class="input" type="text" data-required id="phone" name="phone" placeholder="Phone Number"  /></div>
    <div class="clearleft"></div>

    <div class="label">Telephone Number (mobile)</div>
    <div class="question"><input class="input" type="text" data-required id="phone" name="mobile" placeholder="Mobile Number"  /></div>
    <div class="clearleft"></div>

    <div class="label">Postal Address</div>
    <div class="question"><textarea data-required placeholder="Postal Address" name="address" id="address"  /></textarea></div>
    <div class="clearleft"></div>

    <hr />

    <div class="label">Event Date</div>
    <div class="question"><input class="input" type="text" data-required id="date" name="date" placeholder="Event Date"  /></div>
    <div class="clearleft"></div>

    <div class="label">Start Time</div>
    <div class="question"><input class="input" type="text" data-required id="starttime" name="starttime" placeholder="Start Time"  /></div>
    <div class="clearleft"></div>

    <div class="label">Finish Time</div>
    <div class="question"><input class="input" type="text" data-required id="finishtime" name="finishtime" placeholder="Finish Time"  /></div>
    <div class="clearleft"></div>

    <div class="label">Event Occasion</div>
    <div class="question"><input class="input" type="text" data-required id="occasion" name="occasion" placeholder="Event Occasion"  /></div>
    <div class="clearleft"></div>

    <hr />

    <div class="label">Venue Name</div>
    <div class="question"><input class="input" type="text" data-required id="venuename" name="venuename" placeholder="Venue Name"  /></div>
    <div class="clearleft"></div>

    <div class="label">Venue Postcode</div>
    <div class="question"><input class="input" type="text" data-required id="venuepostcode" name="venuepostcode" placeholder="Venue Postcode"  /></div>
    <div class="clearleft"></div>

    <hr />

    <div class="label">Further Information Required</div>
    <div class="question"><textarea data-required  placeholder="Further Information Required" name="inforequired" id="inforequired"  /></textarea></div>
    <div class="clearleft"></div>

    <div class="label">How Did You Hear About Us?</div>
    <div class="question"><input class="input" type="text" data-required id="advertsource" name="advertsource" placeholder="How Did You Hear About Us?"  /></div>
    <div class="clearleft"></div>

    <div class="submitme"><input type="submit"  value="Send" name="submitme" id="submitme"  /></div>

    <input name="ispost" value="true" type="hidden"  />

    </form>
    </div>

    <div id="errors"  style="color:red"></div>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,447
    Thanks
    76
    Thanked 4,372 Times in 4,337 Posts
    At a *guess*: Because you don't return false from the validation.

    Try
    Code:
            invalid:function(){alert("Please Input all fields"); return false;}
    But that is said without having any idea in the world what jquery-validate.min.js looks like, and you neglected to show the code for it.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New Coder
    Join Date
    Jun 2009
    Posts
    68
    Thanks
    22
    Thanked 0 Times in 0 Posts
    Code:
    /* http://plugins.jquery.com/validate */
    ;(function(a,b,c,d){var e=['input:not([type]),input[type="color"],input[type="date"],input[type="datetime"],input[type="datetime-local"],input[type="email"],input[type="file"],input[type="hidden"],input[type="month"],input[type="number"],input[type="password"],input[type="range"],input[type="search"],input[type="tel"],input[type="text"],input[type="time"],input[type="url"],input[type="week"],textarea',"select",'input[type="checkbox"],input[type="radio"]'],f=e.join(","),g={},h=function(a,c){var f={pattern:!0,conditional:!0,required:!0},h=b(this),i=h.val()||"",j=h.data("validate"),k=j!==d?g[j]:{},l=h.data("prepare")||k.prepare,m=h.data("pattern")||("regexp"==b.type(k.pattern)?k.pattern:/(?:)/),n=h.attr("data-ignore-case")||h.data("ignoreCase")||k.ignoreCase,o=h.data("mask")||k.mask,p=h.data("conditional")||k.conditional,q=h.data("required"),r=h.data("describedby")||k.describedby,s=h.data("description")||k.description,t=h.data("trim"),u=/^(true|)$/i,v=/^false$/i,s=b.isPlainObject(s)?s:c.description[s]||{};if(q=""!=q?q||!!k.required:!0,t=""!=t?t||!!k.trim:!0,u.test(t)&&(i=b.trim(i)),b.isFunction(l)?i=l.call(h,i)+"":b.isFunction(c.prepare[l])&&(i=c.prepare[l].call(h,i)+""),"regexp"!=b.type(m)&&(n=!v.test(n),m=n?RegExp(m,"i"):RegExp(m)),p!=d)if(b.isFunction(p))f.conditional=!!p.call(h,i,c);else for(var x=p.split(/[\s\t]+/),y=0,z=x.length;z>y;y++)c.conditional.hasOwnProperty(x[y])&&!c.conditional[x[y]].call(h,i,c)&&(f.conditional=!1);if(q=u.test(q),q&&(h.is(e[0]+","+e[1])?!i.length>0&&(f.required=!1):h.is(e[2])&&(h.is("[name]")?0==b('[name="'+h.prop("name")+'"]:checked').length&&(f.required=!1):f.required=h.is(":checked"))),h.is(e[0]))if(m.test(i)){if("keyup"!=a.type&&o!==d){for(var A=i.match(m),B=0,z=A.length;z>B;B++)o=o.replace(RegExp("\\$\\{"+B+"(?::`([^`]*)`)?\\}","g"),A[B]!==d?A[B]:"$1");o=o.replace(/\$\{\d+(?::`([^`]*)`)?\}/g,"$1"),m.test(o)&&h.val(o)}}else q?f.pattern=!1:i.length>0&&(f.pattern=!1);var C=b('[id="'+r+'"]'),D=s.valid;return C.length>0&&"keyup"!=a.type&&(f.required?f.pattern?f.conditional||(D=s.conditional):D=s.pattern:D=s.required,C.html(D||"")),"function"==typeof k.each&&k.each.call(h,a,f,c),c.eachField.call(h,a,f,c),f.required&&f.pattern&&f.conditional?(c.waiAria&&h.prop("aria-invalid",!1),"function"==typeof k.valid&&k.valid.call(h,a,f,c),c.eachValidField.call(h,a,f,c)):(c.waiAria&&h.prop("aria-invalid",!0),"function"==typeof k.invalid&&k.invalid.call(h,a,f,c),c.eachInvalidField.call(h,a,f,c)),f};b.extend({validateExtend:function(a){return b.extend(g,a)},validateSetup:function(c){return b.extend(a,c)}}).fn.extend({validate:function(c){return c=b.extend({},a,c),b(this).validateDestroy().each(function(){var a=b(this);if(a.is("form")){a.data(name,{options:c});var d=a.find(f),g=c.namespace;a.is("[id]")&&(d=d.add('[form="'+a.prop("id")+'"]').filter(f)),d=d.filter(c.filter),c.onKeyup&&d.filter(e[0]).on("keyup."+g,function(a){h.call(this,a,c)}),c.onBlur&&d.on("blur."+g,function(a){h.call(this,a,c)}),c.onChange&&d.on("change."+g,function(a){h.call(this,a,c)}),c.onSubmit&&a.on("submit."+g,function(e){var f=!0;d.each(function(){var a=h.call(this,e,c);a.pattern&&a.conditional&&a.required||(f=!1)}),f?(c.sendForm||e.preventDefault(),b.isFunction(c.valid)&&c.valid.call(a,e,c)):(e.preventDefault(),b.isFunction(c.invalid)&&c.invalid.call(a,e,c))})}})},validateDestroy:function(){var a=b(this),c=a.data(name);if(a.is("form")&&b.isPlainObject(c)&&"string"==typeof c.options.nameSpace){var d=a.removeData(name).find(f).add(a);a.is("[id]")&&(d=d.add(b('[form="'+a.prop("id")+'"]').filter(f))),d.off("."+c.options.nameSpace)}return a}})})({sendForm:!0,waiAria:!0,onSubmit:!0,onKeyup:!1,onBlur:!1,onChange:!1,nameSpace:"validate",conditional:{},prepare:{},description:{},eachField:$.noop,eachInvalidField:$.noop,eachValidField:$.noop,invalid:$.noop,valid:$.noop,filter:"*"},jQuery,window);

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Does the "Please Input all fields" alert not display at all or it displays but still submits the form?

  • #5
    New Coder
    Join Date
    Jun 2009
    Posts
    68
    Thanks
    22
    Thanked 0 Times in 0 Posts
    Hello

    It doesn't appear at all:

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,447
    Thanks
    76
    Thanked 4,372 Times in 4,337 Posts
    I *hate* people who write indecipherable code like that. I know, I know: It's minimized.

    So I went and found the documentation for that library, instead.

    http://validation.bassistance.de/validate/

    And no place in those docs does it say anything about being able to use an invalid: option!

    The correct option, per the docs, is invalidHandler:

    You can see that as the third option listed in the page referenced.

    Does this matter? I can't tell.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    You are referring to the wrong plugin. In post #3, you can see the plugin url in a comment
    Code:
    /* http://plugins.jquery.com/validate */

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    @nickburrett, is there any js error?

  • #9
    New Coder
    Join Date
    Jun 2009
    Posts
    68
    Thanks
    22
    Thanked 0 Times in 0 Posts

  • #10
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,447
    Thanks
    76
    Thanked 4,372 Times in 4,337 Posts
    Quote Originally Posted by glenngv View Post
    You are referring to the wrong plugin. In post #3, you can see the plugin url in a comment
    Code:
    /* http://plugins.jquery.com/validate */
    Right you are. Sorry, didn't notice the difference.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #11
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,447
    Thanks
    76
    Thanked 4,372 Times in 4,337 Posts
    What do you mean "NO ERRORS"???

    Chrome reports "Uncaught reference error: $ is not defined" on this line:
    Code:
        $("#contact").validate({
    YOU FORGOT TO INCLUDE the entire jQuery library!

    This line
    Code:
    <script src="contact_form/jquery-validate.min.js" > </script>
    *ONLY* includes the validation library. It does *NOT* include jQuery itself!
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Tags for this Thread

    Posting Permissions

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