jQuery UI dialog Demo (來自 http://jqueryui.com/demos/)

來源:互聯網
上載者:User

 

<!DOCTYPE html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /><html xmlns="http://www.w3.org/1999/xhtml"><br /><head><br /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br /><meta name="Keywords" content="jQuery Dialog Demo" /><br /><meta name="Description" content="jQuery Dialog Demo" /><br /><title>jQuery Dialog Demo</title><br /><link rel="stylesheet" href="http://static.jquery.com/ui/css/base2.css" mce_href="http://static.jquery.com/ui/css/base2.css" type="text/css" media="all" /><br /><link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css" mce_href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css" type="text/css" media="all" /><br /><link rel="stylesheet" href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" mce_href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" type="text/css" media="all" /><br /><mce:script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" mce_src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></mce:script><br /><mce:script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" mce_src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" type="text/javascript"></mce:script><br /><mce:script src="http://jquery-ui.googlecode.com/svn/tags/latest/external/bgiframe/jquery.bgiframe.min.js" mce_src="http://jquery-ui.googlecode.com/svn/tags/latest/external/bgiframe/jquery.bgiframe.min.js" type="text/javascript"></mce:script><br /><mce:script src="http://jquery-ui.googlecode.com/svn/tags/latest/ui/minified/i18n/jquery-ui-i18n.min.js" mce_src="http://jquery-ui.googlecode.com/svn/tags/latest/ui/minified/i18n/jquery-ui-i18n.min.js" type="text/javascript"></mce:script><br /><mce:script src="/js/demos.js" mce_src="js/demos.js" type="text/javascript"></mce:script><br /><mce:script src="/themeroller/themeswitchertool/" mce_src="themeroller/themeswitchertool/" type="text/javascript"></mce:script><br /><mce:style type="text/css"><!--<br />body { font-size: 62.5%; }<br />label, input { display:block; }<br />input.text { margin-bottom:12px; width:95%; padding: .4em; }<br />fieldset { padding:0; border:0; margin-top:25px; }<br />h1 { font-size: 1.2em; margin: .6em 0; }<br />div#users-contain { width: 350px; margin: 20px 0; }<br />div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }<br />div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }<br />.ui-button { outline: 0; margin:0; padding: .4em 1em .5em; text-decoration:none; !important; cursor:pointer; position: relative; text-align: center; }<br />.ui-dialog .ui-state-highlight, .ui-dialog .ui-state-error { padding: .3em; }</p><p>--></mce:style><style type="text/css" mce_bogus="1">body { font-size: 62.5%; }<br />label, input { display:block; }<br />input.text { margin-bottom:12px; width:95%; padding: .4em; }<br />fieldset { padding:0; border:0; margin-top:25px; }<br />h1 { font-size: 1.2em; margin: .6em 0; }<br />div#users-contain { width: 350px; margin: 20px 0; }<br />div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }<br />div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }<br />.ui-button { outline: 0; margin:0; padding: .4em 1em .5em; text-decoration:none; !important; cursor:pointer; position: relative; text-align: center; }<br />.ui-dialog .ui-state-highlight, .ui-dialog .ui-state-error { padding: .3em; }<br /></style><br /><mce:script type="text/javascript"><!--<br />$(function() {</p><p>var name = $("#name"),<br />email = $("#email"),<br />password = $("#password"),<br />allFields = $([]).add(name).add(email).add(password),<br />tips = $("#validateTips");<br />function updateTips(t) {<br />tips.text(t).effect("highlight",{},1500);<br />}<br />function checkLength(o,n,min,max) {<br />if ( o.val().length > max || o.val().length < min ) {<br />o.addClass('ui-state-error');<br />updateTips("Length of " + n + " must be between "+min+" and "+max+".");<br />return false;<br />} else {<br />return true;<br />}<br />}<br />function checkRegexp(o,regexp,n) {<br />if ( !( regexp.test( o.val() ) ) ) {<br />o.addClass('ui-state-error');<br />updateTips(n);<br />return false;<br />} else {<br />return true;<br />}<br />}</p><p>$("#dialog").dialog({<br />bgiframe: true,<br />autoOpen: false,<br />height: 300,<br />modal: true,<br />hide:"slide",<br />buttons: {<br />'Create an account': function() {<br />var bValid = true;<br />allFields.removeClass('ui-state-error');<br />bValid = bValid && checkLength(name,"username",3,16);<br />bValid = bValid && checkLength(email,"email",6,80);<br />bValid = bValid && checkLength(password,"password",5,16);<br />bValid = bValid && checkRegexp(name,/^[a-z]([0-9a-z_])+$/i,"Username may consist of a-z, 0-9, underscores, begin with a letter.");<br />// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/<br />bValid = bValid && checkRegexp(email,/^((([a-z]|/d|[!#/$%&'/*/+/-//=/?/^_`{/|}~]|[/u00A0-/uD7FF/uF900-/uFDCF/uFDF0-/uFFEF])+(/.([a-z]|/d|[!#/$%&'/*/+/-//=/?/^_`{/|}~]|[/u00A0-/uD7FF/uF900-/uFDCF/uFDF0-/uFFEF])+)*)|((/x22)((((/x20|/x09)*(/x0d/x0a))?(/x20|/x09)+)?(([/x01-/x08/x0b/x0c/x0e-/x1f/x7f]|/x21|[/x23-/x5b]|[/x5d-/x7e]|[/u00A0-/uD7FF/uF900-/uFDCF/uFDF0-/uFFEF])|(//([/x01-/x09/x0b/x0c/x0d-/x7f]|[/u00A0-/uD7FF/uF900-/uFDCF/uFDF0-/uFFEF]))))*(((/x20|/x09)*(/x0d/x0a))?(/x20|/x09)+)?(/x22)))@((([a-z]|/d|[/u00A0-/uD7FF/uF900-/uFDCF/uFDF0-/uFFEF])|(([a-z]|/d|[/u00A0-/uD7FF/uF900-/uFDCF/uFDF0-/uFFEF])([a-z]|/d|-|/.|_|~|[/u00A0-/uD7FF/uF900-/uFDCF/uFDF0-/uFFEF])*([a-z]|/d|[/u00A0-/uD7FF/uF900-/uFDCF/uFDF0-/uFFEF])))/.)+(([a-z]|[/u00A0-/uD7FF/uF900-/uFDCF/uFDF0-/uFFEF])|(([a-z]|[/u00A0-/uD7FF/uF900-/uFDCF/uFDF0-/uFFEF])([a-z]|/d|-|/.|_|~|[/u00A0-/uD7FF/uF900-/uFDCF/uFDF0-/uFFEF])*([a-z]|[/u00A0-/uD7FF/uF900-/uFDCF/uFDF0-/uFFEF])))/.?$/i,"eg. ui@jquery.com");<br />bValid = bValid && checkRegexp(password,/^([0-9a-zA-Z])+$/,"Password field only allow : a-z 0-9");</p><p>if (bValid) {<br />$('#users tbody').append('<tr>' +<br />'<td>' + name.val() + '</td>' +<br />'<td>' + email.val() + '</td>' +<br />'<td>' + password.val() + '</td>' +<br />'</tr>');<br />$(this).dialog('close');<br />}<br />},<br />Cancel: function() {<br />$(this).dialog('close');<br />}<br />},<br />close: function() {<br />allFields.val('').removeClass('ui-state-error');<br />}<br />});</p><p>$('#create-user').click(function() {<br />$('#dialog').dialog('open');<br />})<br />.hover(<br />function(){<br />$(this).addClass("ui-state-hover");<br />},<br />function(){<br />$(this).removeClass("ui-state-hover");<br />}<br />).mousedown(function(){<br />$(this).addClass("ui-state-active");<br />})<br />.mouseup(function(){<br />$(this).removeClass("ui-state-active");<br />});<br />});</p><p>// --></mce:script></p><p><div class="demo"><br /><div id="dialog" title="Create new user"><br /><p id="validateTips">All form fields are required.</p><br /><form><br /><fieldset><br /><label for="name">Name</label><br /><input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" /><br /><label for="email">Email</label><br /><input type="text" name="email" id="email" value="" class="text ui-widget-content ui-corner-all" /><br /><label for="password">Password</label><br /><input type="password" name="password" id="password" value="" class="text ui-widget-content ui-corner-all" /><br /></fieldset><br /></form><br /></div></p><p><div id="users-contain" class="ui-widget"><br /><h1>Existing Users:</h1></p><p><table id="users" class="ui-widget ui-widget-content"><br /><thead><br /><tr class="ui-widget-header "><br /><th>Name</th><br /><th>Email</th><br /><th>Password</th><br /></tr><br /></thead><br /><tbody><br /><tr><br /><td>John Doe</td><br /><td>john.doe@example.com</td><br /><td>johndoe1</td><br /></tr><br /></tbody><br /></table><br /></div><br /><button id="create-user" class="ui-button ui-state-default ui-corner-all">Create new user</button><br /></div><!-- End demo --><br /><div class="demo-description"><br /><p>Use a modal dialog to require that the user enter data during a multi-step process. Embed form markup in the content area, set the <code>modal</code> option to true, and specify primary and secondary user actions with the <code>buttons</code> option.</p><br /></div><!-- End demo-description --><br /></body><br /></html>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.