| 1 | <!DOCTYPE html> |
|---|
| 2 | <html lang="en"> |
|---|
| 3 | <head> |
|---|
| 4 | <meta charset="utf-8"> |
|---|
| 5 | <script type="text/javascript" src="../ckeditor.js"></script> |
|---|
| 6 | <script src="sample.js" type="text/javascript"></script> |
|---|
| 7 | <link href="sample.css" rel="stylesheet"> |
|---|
| 8 | <title>HTML5</title> |
|---|
| 9 | </head> |
|---|
| 10 | |
|---|
| 11 | <body id="index"> |
|---|
| 12 | <p>Editor1 (alert and block):</p> |
|---|
| 13 | <form method="post" action="sample_posteddata.php"> |
|---|
| 14 | <textarea cols="80" id="editor1" name="editor1" rows="10" required="required"></textarea> |
|---|
| 15 | <input type="submit" value="Submit"> |
|---|
| 16 | </form> |
|---|
| 17 | |
|---|
| 18 | <p>Editor2 (alert, does not block):</p> |
|---|
| 19 | <form method="post" action="sample_posteddata.php"> |
|---|
| 20 | <textarea cols="80" id="editor2" name="editor2" rows="10" required></textarea> |
|---|
| 21 | <input type="submit" value="Submit"> |
|---|
| 22 | </form> |
|---|
| 23 | |
|---|
| 24 | <script type="text/javascript"> |
|---|
| 25 | CKEDITOR.replace( 'editor1' ).on( 'required', function( evt ) { |
|---|
| 26 | alert( 'Content of editor1 is required.' ); |
|---|
| 27 | evt.cancel(); // Prevent submit. |
|---|
| 28 | } ); |
|---|
| 29 | |
|---|
| 30 | CKEDITOR.replace( 'editor2' ).on( 'required', function() { |
|---|
| 31 | alert( 'Content of editor2 is required.' ); |
|---|
| 32 | } ); |
|---|
| 33 | </script> |
|---|
| 34 | </body> |
|---|
| 35 | </html> |
|---|