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.

Jayesh Patel
2,11818 silver badges22 bronze badges
asked Apr 10, 2016 at 7:02

1 Answer 1

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>
answered Apr 10, 2016 at 7:42

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.