<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic"%>
<%@ page isELIgnored="false" %>
<html:html locale="true">
	<head>
	    <script type="text/javascript"src="${pageContext.request.contextPath}/js/jquery.js"></script>
		<link href="${pageContext.request.contextPath}/css/style.css" rel="stylesheet" type="text/css">
		<title>添加黑白名单</title>
		<script language="javascript">
		<!--
		function onSubmit() {
       	    var form = document.CallBarringForm;
       	    if ($("#resText").html() != '')
       	    {
       	    	alert("限制号码输入不合法!");
       	    	return false;
       	    }
       	    if (form.limitPhone.value == "") {
       	    	alert("限制号码不能为空!");
       	    	return false;
       	    } else {
       	    	return true;
       	    }
   	    }
   	    
   	    // 验证黑白名单号码是否已存在
   	    function validLimitPhone() {
            $.ajax({
	            type:"post", //请求方式
	            url:"${pageContext.request.contextPath}/callBarringAction.do", //发送请求地址
	            data:{ //发送给数据库的数据
	              method:$("#validLimitPhoneMethod").val(),
	              limitPhone:$("#limitPhone").val()
	            },
	            
	            //请求成功后的回调函数有两个参数
	            success:function(data, textStatus){
	              $("#resText").html(data);
	            }
            });
        }
		//-->
		</script>
	</head>
	<body>
    	<form action="${pageContext.request.contextPath}/callBarringAction.do" name="CallBarringForm" method="post" onsubmit="return onSubmit()">
	   		<input type="hidden" name="validLimitPhoneMethod" id="validLimitPhoneMethod" value="validLimitPhone" />
	   		<input type="hidden" name="method" value="insertCallBarring" />
	   		<table width="98%" align="center" border="0" cellpadding="4" cellspacing="1" class="list">
           		<tr align="center"> 
          			<td colspan="2" width="100%" class="title_td" align="center"> 
          				<div class="title_font">添加黑白名单</div>
         			</td>
        		</tr>
        		<tr>
              		<td class="td_left">类型：</td>
              		<td class="td_right"> 
		              <select name="limitType">
		              		<option value="0">黑名单</option>
		              		<option value="1">白名单</option>
	              		</select>*
              		</td>
            	</tr>
        		<tr>
              		<td class="td_left">限制号码：</td>
              		<td class="td_right"> 
              			<input type="text" name="limitPhone" id="limitPhone" size="20" onchange="validLimitPhone()" />*
              			<div id="resText"></div>	
              		</td>
            	</tr>
            	<tr>
              		<td class="td_left">描述信息：</td>
              		<td class="td_right"> 
              			<textarea name="description" cols="70" rows="3"></textarea>
              		</td>
            	</tr>
	            <tr>
	            	<td align="center" colspan="2">
		            	<input type="submit" value="确定" class="btn_style"/>&nbsp;&nbsp;
		            	<input type="reset" value="重置" class="btn_style"/>&nbsp;&nbsp;
		            	<input type="button" value="返回" class="btn_style" onclick="history.go(-1)">
		            </td>
	            </tr>
			</table>
       </form>
	</body>
</html:html>