标签:border bsp 文本 pre oninput var blog rip war
HTML部分
<p class="psy"><span>sn:</span><input type="text" class="intx" oninput="checkSame()"><span></span></p> <p class="psy"><span>sn:</span><input type="text" class="intx" oninput="checkSame()"><span></span></p> <p class="psy"><span>sn:</span><input type="text" class="intx" oninput="checkSame()"><span></span></p> <p class="psy"><span>sn:</span><input type="text" class="intx" oninput="checkSame()"><span></span></p> <p class="psy"><span>sn:</span><input type="text" class="intx" oninput="checkSame()"><span></span></p> <p class="psy"><span>sn:</span><input type="text" class="intx" oninput="checkSame()"><span></span></p> <span id="cc" style=" display:block; line-height:50px; width:200px;color:red; border:#036 solid 1px;">456</span>
JavaScript部分,引入jQuery
function checkSame(){ var dataArray = new Array(); var inputArray = $(".intx"); for(var i = 0; i<inputArray.length; i++){ dataArray[i] = inputArray[i].value; } checkArray(dataArray); } function checkArray(someArray){ var newArray = someArray.sort(); for(var i=0;i<newArray.length;i++){ if(newArray[i] == newArray[i+1] && newArray[i]!=0){ $(‘#cc‘).html(‘sn重复输入‘); break; }else{ $(‘#cc‘).html(‘sn可用‘); } } }
标签:border bsp 文本 pre oninput var blog rip war
原文地址:http://www.cnblogs.com/zishan/p/6149720.html