-
of course easy for you, just one line of code.
//build-in rule is't like the "required", it can't be translate such as required(...)
//you can see config.js to get details
SMValidator.setLang({number: 'please entry numbers', email: 'please entry a corrected email'});
numbers:
email :
-
your boss praise you for your job, but the new demand is here.
he want a validation with async, server end to tell you pass or fail.
do you want to give your boss a stick? but it's you job, come on baby~~
<input type="text" name="test5">
<script>
new SMValidator('form', {
fields: {
test5: {
required: true,
async: 'please wait for validation...'
}
}
});
//"forceFlag" force result, 1-pass 2-fail
//"asyncMessage" the message of async validation
//remember "manul" in tutor1? there is SMValidator.validate(), too
SMValidator.validate('[name="test5"]', {forceFlag: 2, asyncMessage: 'fail validate by server'});
</script>
-
later, your boss submit the form without entry any thing but it's submited successfully.
this bug will be given you to deal with without doubt.
//"submit" can prevent the default submit action.
new SMValidator('form', {
submit: function(valid, form) {
if(valid) form.submit();
}
});
-
get here, may be you thought it's the end of your boss's demand. don't guess the thought of your boss forever. please see tutor4