1

When using jquery .change on an input the event will only be fired when the input loses focus

In my case, I need to make a call to the service (check if value is valid or empty) as soon as the input value is changed. How could I accomplish this? this validation for without using submit event.

2

Open file js/prototype/validation.js

Find the following section

Validation.defaultOptions = {
    onSubmit : true,
    stopOnFirst : false,
    immediate : false,
    focusOnError : true,
    useTitles : false,
    addClassNameToContainer: false,
    containerClassName: '.input-box',
    onFormValidate : function(result, form) {},
    onElementValidate : function(result, elm) {}
};

and change immediate : false, to immediate : true,

Or you can create new js file with content

Validation.defaultOptions.immediate = true;

and add it below js/prototype/validation.js

Or add inline js before your form creation

<script type="text/javascript">
    Validation.defaultOptions.immediate = true;
<script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.