In magento some times we need to validate some fields like username on its availability.
So in that case we need to run the validation function on an event change of the element
In order to do that we need to add an function for example onblur to the element as shown below

<input class="input-text required-entry" id="firstname" type="text" name="firstname" onblur="validate_field(this)"/>

and add the javascript function inside the script tag like below

function validate_field(id){
  Validation.validate(id);
}

Hope this post helps to add form validation on change in magento

One Comment on “Form validation on change in magento

  1. Farhan
    June 8, 2015

    This is exactly i was looking for. Works like a charm

Leave a Reply

Your email address will not be published. Required fields are marked *