Feature Idea
misner opened this issue · comments
One event that is according to use really important and frequent and missing is change.
We have checked and blank/not_blank.
What about the cases where a user has an active amdin field filled, then change the content of this field. If it is dynamic, it could also trigger something. Could we have an event 'change' ?
Regards,
Michael
Good idea @misner
I have just implemented it (new event added "changed"), give it a try.
Note: it is fired only the first time an input is changed (currently I don't check if the value is set back to the original value)
Sure. Post your code if you like.
But I would like to keep the plugin generic, a specific request should be managed with a custom function as you already did.
Here's the gist of our js custom script (on field change it impacts field 2)
$(document).ready(function() {
$('.field1').on('change', function(){
console.log("detected change in a field1 value");
$targetInput = $(this).find( 'input' );
if ( $targetInput.val() != "" ) {//restrict: trigger if video has not been removed
$targetField2Input = $(this).closest( 'fieldset' ).find( '.wrapper_html_class input' );//target via wrapper_html put on field 2
$targetField2Hints = $(this).closest( 'fieldset' ).find( '..wrapper_html_class2 .inline-hints' );
//clear related Image url value
$targetField2Input.val('');
//explain to user he must change field2 following new/change in video url field
if ( $targetField2Hints.find('.status_tag.red').length === 0 ) { //restrict: if the red alert is not already present
$targetField2Hints.prepend( "<p class='status_tag red'>You have entered a new field1 value or changed the field1 value, so please adjust also Field2 valuel. </p>" );
}
//remove alert msg when user begins typing in the field
$targetField2Input.on('keydown', function(){
$targetField2Hints.find('.status_tag.red').remove();
});
}
});
});
Good, thank you for sharing your code Misner