From dfa935826eec827e70d0a7d0337fc0bcbf39e793 Mon Sep 17 00:00:00 2001 From: Alex Ball Date: Wed, 3 Apr 2019 23:45:35 +0100 Subject: [PATCH] Use JQuery to show and hide help text --- static/js/forms.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/static/js/forms.js b/static/js/forms.js index 388a97c..f67cb64 100644 --- a/static/js/forms.js +++ b/static/js/forms.js @@ -36,3 +36,18 @@ $( ".form-list > li:last-child" ) $( "input[list='keyword-list']" ).parent().filter(":last-child") .one( "change", autoduplicate ); + +/* Cleaning help text */ + +$( ".form-group" ).find( ".help-block" ).hide(); + +$( ":input" ).focus(function() { + $( this ).closest( ".form-group" ).find( ".help-block" ) + .filter( ":hidden" ).show(400); +}); + +$( ".form-group" ).focusout(function (event) { + if ( $( this ).has( event.relatedTarget ).length == 0 ) { + $( this ).find( ".help-block" ).hide(400); + } +});