Skip to content Skip to sidebar Skip to footer

Modal Window Instead Alert

I need to modify this script so that at the end of the allowed number of characters, instead of alert user can see a modal warning window, which disappears after N seconds. In this

Solution 1:

You could use the jQuery library to create a modal dialog: http://jqueryui.com/demos/dialog/#modal

Here's an example using your code: http://jsfiddle.net/ZZsTS/

JS

$( "#dialog-modal" ).dialog({
  height: 140,
  modal: true,
  autoOpen: false,
  //set a timeout of 3 secs to close it again, when openedopen: function(event, ui) {
    setTimeout("$('#dialog-modal').dialog('close')", 3000);
  },
  //when closing, make the textarea readonly
  close : function(){
    $('textarea').attr('readonly', 'readonly');
  }
});

open dialog with

$('#dialog-modal').dialog('open');

HTML

<textarea></textarea><divid="dialog-modal"title="Basic modal dialog"><p>Stop !</p></div>

Post a Comment for "Modal Window Instead Alert"