Solved

Check for  form values

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

937 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

10 Experts available now in Live!

Get 1:1 Help Now