Solved

Check for  form values

Posted on 2011-09-29
4
199 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Read about why website design really matters in today's demanding market.
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now