jquery - Check for e-mail or phone validation (geektantra plugin) -
i'm validating form user either fills in phone number or e-mailadres. @ least 1 of 2 needs filled in.
i'm using validation plugin: http://www.geektantra.com/projects/jquery-form-validate/advanced_demo/
i think should this, doesn't seem work:
expression: "if ((val) || jquery('#email').val()) return true; else return false;",
hoping help.
if trying validate phone or email,
try using this,
expression: if ((val.match(/^[0-9]*$/) && val.length == 10) || val.match(/^[^\\w][a-za-z0-9\\_\\-\\.]+([a-za-z0-9\\_\\-\\.]+)*\\@[a-za-z0-9_]+(\\.[a-za-z0-9_]+)*\\.[a-za-z]{2,4}$/)) return true; else return false;
this checks if phone number or email , if 1 of valid then, returns true.
try if having 2 input fields,
jquery(this).parents("form").submit(function(){ var isformvalid = true; if(selfid != <phone feild> || selfid != <email feild> ){ if (validate_field('#' + selfid)) else isformvalid = false; } if(validate_field('#' + <phone feild>) || validate_field('#' + <email feild>)){ if(isformvalid == true){ return true; }else{ return false; } } });
Comments
Post a Comment