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.
1 Answer 1
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>
Explore related questions
See similar questions with these tags.