Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
- <title>jQuery validation plug-in - main demo</title>
- <link rel="stylesheet" type="text/css" media="screen" href="http://www.zinomen.com/test/css/screen.css" />
- <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
- <script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
- <script type="text/javascript" src="http://www.tinymce.com/js/tinymce/jscripts/tiny_mce/jquery.tinymce.js"></script>
- <script type="text/javascript" src="http://www.zinomen.com/test/tiny_mce/tiny_mce.js"></script>
- <script type="text/javascript">
- $(document).ready(function() {
- $('#message').tinymce({
- // Location of TinyMCE script
- script_url : 'http://www.zinomen.com/test/tiny_mce/tiny_mce.js',
- // General options
- theme : "advanced",
- plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
- // Theme options
- theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
- theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
- theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
- theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
- theme_advanced_toolbar_location : "top",
- theme_advanced_toolbar_align : "left",
- theme_advanced_statusbar_location : "bottom",
- theme_advanced_resizing : true,
- // Example content CSS (should be your site CSS)
- content_css : "css/content.css",
- // Drop lists for link/image/media/template dialogs
- template_external_list_url : "lists/template_list.js",
- external_link_list_url : "lists/link_list.js",
- external_image_list_url : "lists/image_list.js",
- media_external_list_url : "lists/media_list.js",
- });
- $.validator.addMethod("textInMce", function textInMce(value, element){
- return $('#message').text().length > 15 && $('#tinymce').text().length > 15;
- }, "Please use more then 15 chars.");
- var container = $('div.error');
- $("#signupForm").validate({
- errorContainer: container,
- errorLabelContainer: $("ul", container),
- ignore: "",
- wrapper: 'li',
- rules: {
- firstname: {
- required: true,
- minlength: 2
- },
- lastname: {
- required: true,
- minlength: 2
- }
- },
- messages: {
- firstname: {
- required: "Please fill in your firstname",
- minlength: "Your firstname must consist of at least 2 characters"
- },
- lastname: {
- required: "Please fill in your lastname",
- minlength: "Your lastname must consist of at least 2 characters"
- }
- }
- });
- $('input.submit').click(function(){
- if ($("#signupForm").valid())
- alert('succes');
- else
- alert($('#message').text().length);
- });
- });
- </script>
- <style type="text/css">
- #signupForm { width: 670px; }
- #signupForm label.error {
- margin-left: 10px;
- width: auto;
- display: inline;
- }
- </style>
- </head>
- <body>
- <div id="main">
- <div class="error" style="display: none;">
- <h2>Something goes wrong!</h2>
- <ul>
- <li><label for="firstname" class="error">Please fill in your firstname</label></li>
- <li><label for="lastname" class="error">Please fill in your lastname</label></li>
- </ul>
- </div>
- <form class="cmxform" id="signupForm" method="post" action="#">
- <fieldset>
- <legend>Validating a complete form</legend>
- <p>
- <label for="firstname">Firstname</label>
- <input id="firstname" name="firstname" type="text" />
- </p>
- <p>
- <label for="lastname">Lastname</label>
- <input id="lastname" name="lastname" type="text" />
- </p>
- <p>
- <label for="message">Message</label>
- <textarea id="message" name="message" rows="20" cols="20" class="textInMce"></textarea>
- </p>
- <p>
- <input class="submit" type="submit" value="Submit"/>
- </p>
- </fieldset>
- </form>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement