Skip to main content

Posts

Showing posts from August, 2022
 jQuery select change show/hide div event <script>   $(document).ready(function(){     $('#selectID').on('change', function() {       if ( this.value == 'red')       {         $("#divid").show();       }       else       {         $("#divid").hide();       }     }); }); </script>
Prevent SweetAlert to be closed on clicking outside the popup window If you are using Sweet Alert 2, you can use this configuration allowOutsideClick: false, To stop closing by escape key use below also: allowEscapeKey: false,
  Check if inputs are empty using jQuery Option 1 $( 'input' ). blur ( function ( ) { if ( !$( this ). val () ) { $( this ). parents ( 'p' ). addClass ( 'warning' ); } }); Option 2 $( input' ). blur ( function ( ) { if ( $( this ). val (). length === 0 ) { $( this ). parents ( 'p' ). addClass ( 'warning' ); } }); Option 3 $( input' ). blur ( function ( ) { if ( ! this . value ) { $( this ). parents ( 'p' ). addClass ( 'warning' ); } });