I need to array through all the input elements within a form to check if they are left empty (validation is also on the server). Mootools is being used a library for the site so here is my code:
$$('#emeraldForm input').addEvent("submit",function(){
//form validation
});
I would like to do that before the form gets submitted. The empty ones will than be given an error classes which will be removed on ‘keyup’ event.
If you don’t want to use HTML5 required attribute or Mootool’s More validation providers (inline validation) than you can do something simple like assigning all required input[type=text] elements and input[type=checkbox] elements
and then do something like this:
I am adding class error which can be in CSS specified as red background or some icon next to input element or similar attention drawing thing.