liquinas Posted August 21, 2008 Share Posted August 21, 2008 Hi all! I have this function which checks for empty fields that have class="required" on a form before submitting. What I want to know is if I can use more than one qualifying flag. For example both class="required" and class="peanut" but not anything else. function validate() { var result = $('.required').map(function (index, domElement) { var flag = "true"; if ($(this).val().length < 1) { $(this).css({backgroundColor:"red"}); flag = "false"; } else { $(this).css({backgroundColor:"white"}); } return flag; }); return result; } Thanks in advance for any advice Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 22, 2008 Share Posted August 22, 2008 You can specify more than one class by separating them by spaces: <p class="require peanut"> http://msdn.microsoft.com/en-us/library/ms533560(VS.85).aspx Quote Link to comment Share on other sites More sharing options...
liquinas Posted August 22, 2008 Author Share Posted August 22, 2008 Thanks for the reply. What I'm looking for is for .peanut to be an alternate required class in the first line of the function. Something like: var result = $('.required' OR '.peanut').map(func... How could I write this? Quote Link to comment Share on other sites More sharing options...
corbin Posted August 22, 2008 Share Posted August 22, 2008 Is that jQuery? If so: var result = $(".required,.peanut").blah(); Quote Link to comment Share on other sites More sharing options...
liquinas Posted August 23, 2008 Author Share Posted August 23, 2008 THANK JOO! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.