Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

validate

Posted on 2011-03-15
5
Medium Priority
?
358 Views
Last Modified: 2012-05-11
using jquery.validate  
what would be the syntax to validate just one field within a form?

keep in mind that the one field is within a form and the entire form is also validated.
but this is a different function where an element is clicked and the field in question is validated on being blank or not.
thanks
0
Comment
Question by:dgrafx
  • 3
  • 2
5 Comments
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 35136971
you just have to capture the onclick event of the element and do the validation.

Where are you struck?
0
 
LVL 25

Author Comment

by:dgrafx
ID: 35136995
where am i stuck?
start with syntax ...
0
 
LVL 40

Accepted Solution

by:
Gurvinder Pal Singh earned 2000 total points
ID: 35137021
below is the sample of how to capture the onclick event on an element and check if another field is empty
$("#elementId").bind("click", function(){
   var value = $("#anotherElementId").val();
   if ( value.length == 0  )
   {
      alert("field is empty");
      $("#anotherElementId").focus();
   }
});

0
 
LVL 25

Author Comment

by:dgrafx
ID: 35137062
yeah ok - i'll just use something like that.

to explain: i'm working on a project where the owner wants EVERYTHING to be jquery.
ya know - the latest buzz words and catch phrases ...
so some of my really simple questions are really saying "how do you do this using jquery"

thanks a lot
0
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 35137075
Its Ok, hurl in your questions :)

Thanks for the points
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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)

916 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