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 3 of 3

Thread: contact form

  1. #1
    New Coder
    Join Date
    Nov 2011
    Posts
    77
    Thanks
    4
    Thanked 0 Times in 0 Posts

    contact form

    I have this contact form and I don't know how to modify it.
    I added some checkbox and a dropdown select menu, and I don't know how to validate them... or atache to the sent message.

    Code:
    <script type='text/javascript'>
        $(document).ready(function(){
            $('#send_message').click(function(e){
                e.preventDefault();
                
                /* declare the variables, var error is the variable that we use on the end
                to determine if there was an error or not */
                var error = false;
                var name = $('#name').val();
                var email = $('#email').val();
                var subject = $('#subject').val();
    
                
              
                if(name.length == 0){
                    var error = true;
                    $('#name_error').fadeIn(500);
                }else{
                    $('#name_error').fadeOut(500);
                }
                if(email.length == 0 || email.indexOf('@') == '-1'){
                    var error = true;
                    $('#email_error').fadeIn(500);
                }else{
                    $('#email_error').fadeOut(500);
                }
                if(subject.length == 0){
                    var error = true;
                    $('#subject_error').fadeIn(500);
                }else{
                    $('#subject_error').fadeOut(500);
                }
    
                
              
                if(error == false){
                    
                    $('#send_message').attr({'disabled' : 'true', 'value' : 'Sending...' });
                    
                    
                    $.post("send_email.php", $("#contact_form").serialize(),function(result){
                        
                        if(result == 'sent'){
                             $('#cf_submit_p').remove();
                            $('#mail_success').fadeIn(500);
                        }else{
                            $('#mail_fail').fadeIn(500);
    
                            $('#send_message').removeAttr('disabled').attr('value', 'Send The Message');
                        }
                    });
                }
            });    
        });
    </script>

    this is a usual line

    Code:
    <p>
    Your Name:
    <div id='name_error' class='error'><img src='images/error.png'> We don't talk to strangers.</div>
    <div><input type='text' name='name' id='name'></div>
    </p>

    and this is what I wanna add

    Code:
    <table width='100%' border='0'>
      <tr>
        <td><input type='checkbox' name='Yes' value='Field1'></td>
        <td>Field1</td>
      </tr>
    <tr><td><input type='checkbox' name='Yes' value='Field2'></td>
        <td>Field2</td></tr>
       <tr><td><input type='checkbox' name='Yes' value='Field3'></td>
    
        <td>Field3</td></tr>
      <tr><td><input type='checkbox' name='Yes' value='Field4'> </td>
        <td>Field4</td>
      </tr>
    
      <tr><td><input type='checkbox' name='Yes' value='Field5'> </td>
        <td>Field5</td>
      </tr>
    </table>
    
    <p>&nbsp;</p>
    <p>
    Numbers of pages:
    <select name="pages">
    <option value="5">0 - 5 pages</option>
    <option value="15">5 - 15 pages</option>
    <option value="30">15 - 30 pages</option>
    <option value="31"> > 30 pages</option>
    </select>
    </p>
    <p>&nbsp;</p>

    Thanks

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Moving from Java forum to Javascript Frameworks forum.

  • #3
    New Coder
    Join Date
    Nov 2011
    Posts
    77
    Thanks
    4
    Thanked 0 Times in 0 Posts
    still needing help


  •  

    Posting Permissions

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