username:<input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" />
password:<input type="password" name="password" id="password" value="" class="text ui-widget-content ui-corner-all" />
</fieldset>
</form>
</div>
´ó¼Ò¿ÉÒÔ¿´µ½Ã¿¸öinput±êÇ©¶¼ÓÐÒ»¸öclassÊôÐÔ£¬Ö¸¶¨ÁË3¸öclassÑùʽ¡£Õâ¾ÍÊÇjQueryUI¸øÎÒÃÇÌṩµÄ£¬²»ÐèÒªÎÒÃÇȥдÑùʽ±íÎļþ¡£
¸ü¶àµÄÊôÐÔÓ¦Óôó¼Ò¿ÉÒԲο¼¹Ù·½ÌṩµÄÎĵµ£¬ÓÉÓÚÊôÐԽ϶࣬²»ÔÙÒ»Ò»½éÉÜ¡£¶¼ºÜ¼òµ¥£¬ÐèÒªÓõ½µÄʱºò²éѯһϼ´¿É
ÏÂÃæ˵˵dialogÖеÄʼþµ÷Óá£ÔÚÉÏÃæµÄÀý×ÓÖÐdialogÖ»ÓÐÒ»¸ö°´Å¥£¬ÓÃÓڵǼ¡£Èç¹ûÎÒÏëÌí¼ÓÁíÍâÒ»¸ö°´Å¥£º¹Ø±Õ£¬µ±ÎÒµã»÷¹Ø±Õʱ¹Ø±Õdialog¸ÃÈçºÎ×öÄØ£¿ÔÚjQueryUIÖУ¬¶àÊý×é¼þµÄʼþ¶¼Ê¹ÓÃÈçϵÄÐÎʽÀ´µ÷Óãº
$("#dialog").dialog("close");ÆäÖÐclose¾ÍÊÇʼþµÄÃû³Æ£¬ÕâÑùµ±ÎÒµã»÷Õâ¸ö°´Å¥Ê±¾Í¿ÉÒԹرոÃdialogÁË¡£Èç¹ûÒª´ò¿ªdialogÒ²ÊÇͬÑùµÄµÀÀí¡£$("#dialog").dialog("open");Õâ¸öÓÃÓÚ´ò¿ªdialog¡£¸ü¶àµÄ·½·¨Çë²éÔÄÎĵµ£¬Ê¼þµÄ¹¦Äܲ»Ò»Ñù£¬µ«ÊÇÓ÷¨»ù±¾Ò»Ö£º
¶¼ÊÇ$.dialog("ʼþÃû³Æ");ÕâÖÖÐÎʽ
ÏÂÃæÎÒÃÇÒÔdialogΪÀý£¬À´ÊµÏÖÒ»¸öʵÓÃdialog+form±íµ¥½øÐÐajax×¢²áµÄʵÀý(ֻдǰ̨ʵÏÖ£¬ºǫ́Çë¸ù¾Ý×Ô¼ºËùÓõķþÎñÆ÷¶ËÓïÑÔ½øÐÐʵÏÖ¡£)
Ê×ÏÈ¿´×¢²áµÄdialogÖж¼ÓÐʲôÄÚÈÝ¡£Ö÷Ò³Ò³ÃæµÄdialogÈçÏÂËùʾ£º
×¢²á±íµ¥ÖÐÓÐÓû§Ãû¡¢ÃÜÂë¡¢emailºÍÓû§µÄÉúÈÕÒÔ¼°¡°Ìá½»¡±ºÍ¡°È¡Ïû°´Å¥¡±
¹¦ÄÜÃèÊö£º
µ±Óû§µã»÷Ìá½»µÄʱºòÊ×ÏȽøÐпͻ§¶ËµÄÑéÖ¤£¬Èç¹ûÓв»·ûºÏÒªÇóµÄÔò¸øÓëÓû§ÌáʾÐÅÏ¢¡£ÌáʾÐÅÏ¢»áÒÔÐÑÄ¿µÄ·½Ê½ÏÔʾÔÚ±íµ¥µÄ×îÉÏ·½£¬²»ÊÇalert()µÄ·½Ê½¡£µ±Ñé֤ͨ¹ýºóµã»÷Ìá½»°´Å¥·¢ÆðajaxÇëÇ󣬽«±íµ¥Êý¾Ý·¢Ë͵½ºǫ́´¦Àí£¬×îÖռǼÔÚÊý¾Ý¿âÖУ¬×¢²á³É¹¦
ÏÈÀ´¿´×¢²á±íµ¥ÖÐdivÖеÄÄÚÈÝ£º
<div id="register-form" class="ui-widget ui-widget-content ui-corner-all" title="Óû§×¢²á">
<p class="validateTips">ËùÓÐµÄ±íµ¥Óò¶¼Îª±ØÌîÏî.</p>
<form id="reg-form">
<fieldset>
̞:<input type="text" name="uname" id="uname" value="" class="text ui-widget-content ui-corner-all" />
ÃÜÂë:<input type="password" name="upass" id="upass" value="" class="text ui-widget-content ui-corner-all" />
email:<input type="text" name="email" id="email" value="" class="text ui-widget-content ui-corner-all" />
ÉúÈÕ:<input type="text" readonly="readonly" name="birth" id="birth" value="" class="text ui-widget-content ui-corner-all" />
</fieldset>
</form>
</div>
ÉϱߵÄdivÖÐÏÔʾµÄ¾ÍÊÇ×¢²á±íµ¥µÄÄÚÈÝ¡£Ò»¹²ËÄÏºÍ´ó¼Ò¿´µ½µÄdialogÖеÄÊÇÒ»ÖµÄ
È»ºóÀ´¿´ÈçºÎ¶ÔÕâЩÊý¾Ý½øÐÐÑéÖ¤£¬ÑéÖ¤´úÂëÈçÏ£º
//×¢²á±íµ¥Ïà¹Øº¯ÊýºÍÑéÖ¤
//»ñÈ¡name,password,emailºÍbirth¶ÔÏó²¢½«¶ÔÏóÌí¼Óµ½Ò»¸ö¿Õ¶ÔÏóÖб¸ÓÃ
var uname = $("#uname"),
password = $("#upass"),
email = $("#email"),
birth = $("#birth"),
fields = $([]).add(uname).add(password).add(email),
tips = $(".validateTips");
$("#register-form").dialog({
//´ò¿ª¶Ô»°¿òµÄʱºòÒƳý±íµ¥ÓòµÄÑùʽ²¢ÉèÖôíÎóÐÅÏ¢ÏÔʾÎı¾ÎªÄ¬ÈÏÖµ
open:function(){
tips.removeClass().text("ËùÓÐµÄ±íµ¥Óò¶¼Îª±ØÌîÏî.");
fields.removeClass("ui-state-error");
fields.val("");
},
modal:true,//µ¯³ö´øÓÐÕÚÕÖµÄģʽ´°Ìå
autoOpen:false,//²»×Ô¶¯´ò¿ª
buttons:{
Ìá½»:function(){
//µã»÷Ìá½»°´Å¥Ê±Ö´ÐеÄʼþ
var chk = true;
//ÑéÖ¤×ֶ㤶ÈÊÇ·ñ·ûºÏÒªÇó
chk = chk && checkLength(uname,"username",2,15);
chk = chk && checkLength(password,"password",6,20);
chk = chk && checkLength(email,"email",6,40);
chk = chk && checkLength(birth,"birthday",8,10);
//ÕýÔò±í´ïʽÑéÖ¤Óû§ÃûºÍemailÊÇ·ñºÏ·¨
chk = chk && checkReg(name,/^([\u4E00-\uFA29]|[\uE7C7-\uE7F3]|[a-zA-Z])|_\w*$/,"Óû§Ãû±ØÐëÒÔ×Öĸ¡¢Ï»®Ïß»òÕߺº×Ö¿ªÍ·,ÇëÐ޸ĺóÌá½»");
chk = chk && checkReg(email,/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,"ÇëÊäÈëÕýÈ·µÄemail¸ñʽ,¸ñʽÈçÏÂ:admin@yahoo.com");
¡¡