Solved

Check for  form values

Posted on 2011-09-29
4
201 Views
Last Modified: 2012-05-12
I need to display a submit button once values are provided in the required form fields.

Required fields are Name, Title and a Radio button checked.

 I can make it work with the radio button but not the  Name and Title.
  

 jQuery('#agree').click(function() {
 if (! jQuery("input[@name='agree']:checked").val()       ) {
       
        return false;
    }
    else {
       jQuery("#submit").fadeIn();
    }
  });

Open in new window


All I want to do is once all 3 fields have a value, fade in the submit button.

Thanks,
0
Comment
Question by:gvilla23
  • 2
  • 2
4 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 36815890
<< Required fields are Name, Title and a Radio button checked. >>

so the ID of this fields are : Name, Title and Radio

 jQuery('#Name,#Title,#Radio').change(function() {
        if( $("#Name").val().length != 0 && $("#Title").val().length !=0 && $("#Radio").is(":checked") ){
              jQuery("#submit").hide();
        }
        else {
              jQuery("#submit").fadeIn();
        }
});
0
 

Author Comment

by:gvilla23
ID: 36816149
it fades in the submit button when any one of the three fields has a value, I need the submit button to fade in when all the fields have a value.

Here is the code,

  jQuery('#submitName,#title,#agree').change(function() {
        if(jQuery("#submitName").val().length != 0 && jQuery("#title").val().length !=0 && jQuery("#agree").is(":checked") ){
              jQuery("#submit").hide();
        }
        else {
              jQuery("#submit").fadeIn();
        }
});

Thank you,
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 250 total points
ID: 36816163
so :

jQuery('#submitName,#title,#agree').change(function() {
        if(jQuery("#submitName").val().length != 0 && jQuery("#title").val().length !=0 && jQuery("#agree").is(":checked") ){
              jQuery("#submit").fadeIn();
        }
        else {
              jQuery("#submit").hide();
        }
});
0
 

Author Comment

by:gvilla23
ID: 36816216
Perfect!, Thank you.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question