<form id="form" action="" method="post"> <input type="hidden" name="selected" value="" /> <table class="conditionTable"> <tr> <td class="first">用户姓名:</td> <td width="20%"> <div class="condition-text-container"> <input name="user_name" type="text" class="condition-text" maxlength="40"/> </div> </td> <td class="first">用户帐号:</td> <td width="20%"> <div class="condition-text-container"> <input name="user_code" type="text" class="condition-text" maxlength="40"/> </div> </td> </tr> <tr> <td><div class="btn-operation" onClick="searchData()">查询</div> <div class="btn-reset" onClick="resetting()">重置</div></td> </tr> </table> </form> <script type="text/javascript">function searchData() { var inputContext = ($("#form").find("input[type=text]")); var pattern = /[[email protected]#$%^&*()_+-=]$/; var flag = false; $.each(inputContext, function(index, text){ if(pattern.test(text.value)){ $.messager.alert("提示", "搜索条件中含有非法字符,请重新输入!","info"); flag = true;; } }); if(flag){ alert(1); return; } </script>
时间: 2024-10-06 18:32:53