Here's a function for use as an event handler that makes use of this
:
function validate() {
if (this.val() == '') {
return false;
}
}
$(':input').change(validate);
Here's the same function rewritten to take an argument, so that I can call it explicitly:
function validate(field) {
if ($(field).val() == '') {
return false;
}
}
validate($('#customer_name'));
How can I rewrite my validate
function to make it suitable for use as both an event handler, and as a standalone function for me to call?