AJAX+jquery+PHP
来源:互联网 发布:网络客户管理系统 编辑:程序博客网 时间:2024/06/03 17:58
index.html
===================================================================================
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>推荐赠送</title>
<script type="text/javascript" src="jquery-1.2.6.pack.js.js"></script>
<script language="javascript">
$(document).ready(function(){
$("#tjrid").blur(function(){
var Mobile = /^((/(/d{3}/))|(/d{3}/-))?13/d{9}|15[0-9]/d{8}|18[0-9]/d{8}$/;
var tjrPhone = $.trim($("#tjrid").val());
if(tjrPhone==null || "" == tjrPhone){
$("#ts_tjr").html("<font color='green'>该项为可选项,可以不填写....</font>");
}else if(!Mobile.test(tjrPhone)){
$("#ts_tjr").html("<font color='red'>请输入号码,必须是手机号码....</font>");
}else{
$.ajax({
type:"POST",
url:"tjr_ajax.php",
data:"phone="+tjrPhone+"&page=1",
beforeSend:function(){},
success:function(msg)
{
if(msg=="success"){
$("#ts_tjr").html("<font color='green'>推荐人信息正确....</font>");
}else{
$("#tjrid").focus();
$("#ts_tjr").html("<font color='red'>该用户不是嗨客用户,请重新输入....</font>");
}
},
error:function()
{
$("#tjrid").focus();
$("#ts_tjr").html("<span><font color='red'>验证失败...</font></span>");
}
});
}
});
$("#userid").blur(function(){
var Mobile = /^((/(/d{3}/))|(/d{3}/-))?13/d{9}|15[0-9]/d{8}|18[0-9]/d{8}$/;
var usePhone = $.trim($("#userid").val());
if(usePhone==null || "" == usePhone){
$("#ts_use").html("<font color='red'>请输入用户手机号码....</font>");
$("#userid").focus();
}else if(!Mobile.test(usePhone)){
$("#ts_use").html("<font color='red'>请输入正确的用户号码,必须是手机号码....</font>");
$("#userid").focus();
}else{
$.ajax({
type:"GET",
url:"tjr_ajax.php",
data:"phone="+usePhone+"&page=2",
success:function(msg)
{
if(msg=="success"){
$("#ts_use").html("<font color='green'>该号码可用....</font>");
}else{
$("#userid").focus();
$("#ts_use").html("<font color='red'>该号码已经是嗨客用户,请重新输入....</font>");
}
},
error:function()
{
$("#userid").focus();
$("#ts_use").html("<span><font color='red'>验证失败...</font></span>");
}
});
}
});
});
function checkForm(obj)
{
var Mobile = /^((/(/d{3}/))|(/d{3}/-))?13/d{9}|15[0-9]/d{8}|18[0-9]/d{8}$/
if(document.getElementById('tjrid').value!='' && !Mobile.test(document.getElementById('tjrid').value)){
alert('请输入正确的推荐人号码,必须是手机号!');
obj.disable=false;
return false;
}else if(document.getElementById('userid').value==''){
alert('用户号码不能为空!');
obj.disable=false;
return false;
}else if(!Mobile.test(document.getElementById('userid').value)){
alert('请输入正确的用户号,必须是手机号码!');
obj.disable=false;
return false;
}
document.all.form1.submit();
return true;
}
</script>
<style type="text/css">
<!--
*{font-size:12px;}
-->
</style>
</head>
<body>
<center>
<form action="reship.php" method = "post" name="form1" onsubmit="return checkForm(this);">
<table width="900" height="141" border="1">
<tr>
<td colspan="4">用户推荐注册信息:</td>
</tr>
<tr>
<td width="295" height="19"> </td>
<td width="95">推荐人号码:</td>
<td width="120" align="left"><input type="text" name="trjPhone" id="tjrid" value="" size="15"/></td>
<td width="362" align="left"><span id="ts_tjr"> </span></td>
</tr>
<tr>
<td height="19"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>用户手机号:</td>
<td align="left"><input type="text" name="userPhone" id="userid" value="" size="15"/><span style="color:#F00">*</span></td>
<td align="left"><span id="ts_use"> </span></td>
</tr>
<tr>
<td height="19"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="19"> </td>
<td align="center"><input type="submit" value="提交" id="submit" onclick=""/></td>
<td align="center"><input type="reset" value="取消"/></td>
<td> </td>
</tr>
</table>
</form>
</center>
</body>
</html>
===================================================================================
tjr_ajax.php
<?php
require_once('include/conn.php');
header("Cache-Control: no-cache");
$phone= $_REQUEST['phone'];
$page = $_REQUEST['page'];
$num = 0;
$sql = "select * from tb_user where usermobile='$phone'";
$query = mssql_query($sql);
$n = mssql_num_rows($query);
if($page == 1 && $n > 0){
$num = 1;
}
if($page == 2 && $n == 0){
$num = 1;
}
if($num==1){
echo "success";
}else{
echo "error";
}
?>
===================================================================================
有兴趣的 朋友可以研究下:有不懂的可以留言给我。。也可以 QQ:513900855
- jquery php ajax
- jquery php ajax json
- AJAX+jquery+PHP
- php+jquery +ajax +json
- php jquery ajax
- PHP+JQuery+Ajax分页
- php+jquery+ajax+json
- Jquery.Ajax+php 学习笔记
- jquery/ajax/php/json实例
- ajax php jquery (1)
- jquery ajax php 二级联动
- PHP AJAX数据添加(jquery)
- Jquery和PHP Ajax JSON
- jQuery Ajax文件上传(php)
- jQuery php ajax图片上传
- php+ajax+jquery后台程序处理
- Jquery.Ajax+php 学习笔记
- ajax --- jquery + php 代码整理
- VC常用数据类型使用转换详解 (转)
- VC常用数据类型使用转换详解 (转)
- JS调用webservice示例
- 课程设计——数字通信计算机仿真:2PSK调制仿真
- 动态调用WebService的工具类
- AJAX+jquery+PHP
- webservice安全性
- 系统引导前奏
- asp.net2.0操作web.config(增,删,改,查)
- C#:获取所有SQL Server的数据库名称
- sqlplus libclntsh.so.11.1 Permission denied 解决方法
- FTP设置
- 《裂变》作者爆料:欺世盗名者绝非唐骏一人
- 使用J2ME技术实现手机触摸屏开发的方法