Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-28-2012, 11:15 AM   PM User | #1
_user
New Coder

 
Join Date: Nov 2011
Posts: 73
Thanks: 4
Thanked 0 Times in 0 Posts
_user is an unknown quantity at this point
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
_user is offline   Reply With Quote
Old 04-28-2012, 05:11 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,752
Thanks: 4
Thanked 2,468 Times in 2,437 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Moving from Java forum to Javascript Frameworks forum.
Fou-Lu is offline   Reply With Quote
Old 04-28-2012, 09:43 PM   PM User | #3
_user
New Coder

 
Join Date: Nov 2011
Posts: 73
Thanks: 4
Thanked 0 Times in 0 Posts
_user is an unknown quantity at this point
still needing help
_user is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:59 AM.


Advertisement
Log in to turn off these ads.