Update validate.js

added function closures