Created
March 25, 2012 19:00
-
-
Save kevzettler/2199046 to your computer and use it in GitHub Desktop.
default validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="/" method="post" id="form" class="validate[required,funcCall[checkDefault]]"> | |
<input type="submit" value="submit" /> | |
</form> | |
<script type="text/javascript"> | |
/* | |
* Awesome helper function for validationEngine | |
* great for use with autobox | |
* checkes that a field is not the default value before submitting | |
*/ | |
function checkDefault(field, rules, i, options){ | |
if(field.get(0).defaultValue == field.val()){ | |
return "* Field is required"; | |
} | |
} | |
$(doucment).ready(function(){ | |
$('#form').validationEngine('attach', { | |
onValidationComplete: function(form, status){ | |
if(status === true){ | |
$('#form').submit(); | |
} | |
} | |
,promptPosition: "topLeft" | |
,scroll: false | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$(doucement) 8-D field.val() ? field.defaultVal() (extend field) -> placeholder