KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to validate my form so that is out of two blank fields, at least one field must be filled and two fields also can be filled; but can't leave any field blank. I'm using jquery-1.9.1-min.js and here is my html page. <form action="#" class="send_form" id="forgot_pass_form" method="POST"> <fieldset> <div class="send_row"> <label class="padding-top10">Email</label> <input type="text" class="send_email" id="email" name="email" /> <em>You need to type an email address</em> </div> <div class="send_row option">OR</div> <div class="send_row"> <label class="padding-top10">Username</label> <input type="text" class="send_username" id="uname" name="uname" /> </div> <div class="send_row send_submitforgotuser"> <input type="submit" value="Submit" /> </div> </fieldset> </form> Any suggestion how to do it.... ? sofar I have tried jQuery.validator.addMethod("require_from_group", function(value, element, options) { alert("xxx"); var valid = $(options[1], element.form).filter(function() { return $(this).val(); }).length >= options[0]; if(!$(element).data('reval')) { var fields = $(options[1], element.form); fields.data('reval', true).valid(); fields.data('reval', false); } return valid; }, jQuery.format("'Please enter either username/ email address to recover password'/Please fill out at least {0} of these fields.")); Still not getting friutful output.
Tags (comma-separated)
Save Edits
Cancel