拖动排序 验证码

拖动排序 验证码

 
拖动排序 验证码_第1张图片
演示
  • 积木盒子首次投资至少送30元
  • ppmoney注册并实名认证送10元话费,投资再送20元现金
  • 铜板街注册并购买货币基金可以得2000集分宝,本站再返10元,共30元

 

XML/HTML Code
  1. <form class="registration">  
  2.   
  3.             <fieldset>  
  4.                 <legend>拖动排序legend>  
  5.                 <div class="captcha_wrap">  
  6.                     <div class="captcha">  
  7.             Drag to order  
  8.                     div>  
  9.                     <ul id="sortable">  
  10.                         <li class="captchaItem">1li>  
  11.                         <li class="captchaItem">2li>  
  12.                         <li class="captchaItem">3li>  
  13.                         <li class="captchaItem">4li>  
  14.                         <li class="captchaItem">5li>  
  15.                         <li class="captchaItem">6li>  
  16.                     ul>  
  17.                 div>  
  18.                 <a id="formsubmit" class="button">Registera>  
  19.             fieldset>  
  20.         form>  

 

JavaScript Code
  1. "text/javascript">  
  2.             (  
  3.             function($){  
  4.   
  5.                 $.fn.shuffle = function() {  
  6.                     return this.each(function(){  
  7.                         var items = $(this).children();  
  8.   
  9.                         return (items.length)  
  10.                             ? $(this).html($.shuffle(items,$(this)))  
  11.                         : this;  
  12.                     });  
  13.                 }  
  14.   
  15.                 $.fn.validate = function() {  
  16.                     var res = false;  
  17.                     this.each(function(){  
  18.                         var arr = $(this).children();  
  19.                         res =    ((arr[0].innerHTML=="1")&&  
  20.                             (arr[1].innerHTML=="2")&&  
  21.                             (arr[2].innerHTML=="3")&&  
  22.                             (arr[3].innerHTML=="4")&&  
  23.                             (arr[4].innerHTML=="5")&&  
  24.                             (arr[5].innerHTML=="6"));  
  25.                     });  
  26.                     return res;  
  27.                 }  
  28.   
  29.                 $.shuffle = function(arr,obj) {  
  30.                     for(  
  31.                     var j, x, i = arr.length; i;  
  32.                     j = parseInt(Math.random() * i),  
  33.                     x = arr[--i], arr[i] = arr[j], arr[j] = x  
  34.                 );  
  35.                     if(arr[0].innerHTML=="1") obj.html($.shuffle(arr,obj))  
  36.                     else return arr;  
  37.                 }  
  38.   
  39.             })(jQuery);  
  40.   
  41.             $(function() {  
  42.                 $("#sortable").sortable();  
  43.                 $("#sortable").disableSelection();  
  44.                 $('ul').shuffle();  
  45.   
  46.                 $("#formsubmit").click(function(){  
  47.                     ($('ul').validate()) ? alert("Yes") : alert("No");  
  48.                 });  
  49.             });  
  50.           

 


原文地址:http://www.freejs.net/article_biaodan_317.html

 

你可能感兴趣的:(javascript)