会员登录 用户名: 密码: 登录 新会员注册 [找回密码]
当前位置:编程论坛 >> Web开发技术 >> Ajax技术论坛 >> Ajax问题
首页
中资源
  发表一个新主题  发表一个新投票  回复主题 您是本帖的第 3370 个阅读者浏览上一篇主题  刷新本主题   平板显示贴子 浏览下一篇主题
 * 贴子主题:Ajax问题 报告本帖给版主  显示可打印的版本  把本贴打包邮递  把本贴加入论坛收藏夹  发送本页面给朋友  把本贴加入IE收藏夹 
 celeron729 帅哥哟,离线,有人找我吗?
  
  
  头 衔:一无所有
  等 级:职业侠客
  积 分:2387
  专家分:1174
  提问帖:0/0
  回答帖:202
  总帖数:603
  经验值:1030
  注 册:2006-5-10
给celeron729发送一个短消息 把celeron729加入好友 查看celeron729的个人资料 搜索celeron729在Ajax技术论坛的所有贴子 引用回复这个贴子 回复这个贴子

发贴心情 

以下就是html,都是与该文章相同
<%@ page language="java" contentType="text/html;charset=GBK" debug="true" %>
<script language="javascript" type="text/javascript">
<!--
/**//**Ajax开始by Alpha 2005-12-31*/

var http=getHTTPObject()

function handleHttpResponse()
{
    if(http.readyState==4)
    {
        if(http.status==200
        {
            var xmlDocument=http.responseXML;
            if(http.responseText!="")
            {
                document.getElementById("showStr").style.display="";
                document.getElementById("userName").style.background="#FF0000";
                document.getElementById("showStr").innerText=http.responseText;
            }
            else
            {
                document.getElementById("userName").style.background="#FFFFFF";
                document.getElementById("showStr").style.display="none";
            }
        }
        else
        {
            alert("你所请求的页面发生异常,可能会影响你浏览该页的信息!");
            alert(http.statur);
        }
    }
}

function handleHttpResponse1()
{
    if(http.readyState==4)
    {
        if(http.status==200)
        {
            var xmlDocument=http.responseXML;
            if(http.responseText!="")
            {   
                document.getElementById("comNmStr").style.display="";
                document.getElementById("comNm").style.background="#FF0000";
                document.getElementById("comNmStr").innerText=http.responseText;
            }
            else
            {
                document.getElementById("comNm").style.background="#FFFFFF";
                document.getElementById("comNmStr").style.display="none";
            }
        }
        else
        {
            alert("你所请求的页面发生异常,可能会影响你浏览该页的信息");
            alert(http.status);
        }
    }
}

function chkUser()
{
    var url="/chkUserAndCom";
    var name=document.getElementById("userName").value;
    url +=("&userName="+name+"&oprate=chkUser");
    http.open("GET",url,true);
    http.onreadystatechange=handleHttpResponse;
    http.send(null);
    return;
}

function chkComNm()
{
    var url="/chkUserAndCom";
    var name=document.getElementById("comNm").value;
    url +=("&comName="+name+"&oprate=chkCom");
    http.open("GET",url,true);
    http.onreadystatechange=handleHttpResponse1;
    http.send(null);
    return;
}

function getHTTPObject()
{
    var xmlhttp=false;
    if(window.XMLHttpRequest)
    {
        xmlhttp=new XMLHttpRequest();
        if(xmlhttp.overrideMimeType) xmlhttp.ovarrideMimeType('text/xml');
    }
    else
    {
        try
        {
            xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e)
        {
            try
            {
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(E)
            {
                xmlhttp=false;
            }
        }
    }
    return xmlhttp;
}
}

function chkpassword()
{
    var m=document.form1;
    if(len(m.password.value)>20 || len(m.password.value)<5 || ! isStr(m.password.value))
    {
        document.getElementById("passwordStr").style.display="";
        document.getElementById("password").style.background="#ff0000";
        document.getElementById("passwordStr").innerText="对不起,密码必须为英文字母、数字或下划线,长度为5~20!";
    }
    else
    {
        document.getElementById("password").style.background="#ffffff";
        document.getElementById("passwordStr").style.display="none";
    }
}

function chkconfirmPassword()
{
    var m=document.form1;
    if(m.password.value !=m.confiremPassword.value)
    {
        document.getElementById("confirmPasswordStr").style.display="";
        document.getElementById("confiremPassword").style.background="#ff0000";
        document.getElementById("confirmPasswordStr").innerText="对不起,密码与重复密码不一致!";
    }
    else
    {
        document.getElementById("confirmPassword").style.background="#ffffff";
        document.getElementById("confirmPasswordStr").style.display="none";
    }
}

function checkfield()
{
    var m=document.form1;
    if (m.userName.value.length==0)
    {
        alert("对不起,用户名必须为英文字母、数字或下划线,长度为5~20。");
        m.userName.focus();
        return false;
    }
    if(m.password.value.length==0)
    {
        alert("对不起,密码必须为英文字母、数字或下划线,长度为5~20。");
        m.password.focus();
        return false;
    }
    if(m.password.value!=m.confirmPassword.value)
    {
        alert(("对不起,企业名称不能为空!!");
        m.comNm.focus();
        return false;
    }
    m.submit();
}
//-->
</script>
<html>
<body topmargin="0">
<form name="form1" method="post" action="/Control?act=Register">
    <table width="100%">
        <tr><td align="center"><h2>Ajax演示程序</h2></td></tr>
        <tr><td align="center">  ------企业注册 By Alpha</td></tr>
    </table>
    
<hr />
    <table width="400" border="0" cellpadding="1" cellspacing="1" align="center">
    <tr>
        <td><font color="red">*</font></td>
        <td>用户帐号:</td>
        <td>
            <input type="text" name="userName" maxlength="20" style="background:#ffffff"
             onblur="chkUser()" value="" />
            <div id="showStr" style="background-color:#ff9900;display:none"></div>
        </td>
    </tr>
    <tr>
        <td><font color="red">*</font></td>
        <td>企业名称:</td>
        <td>
            <input type="text" name="comNm" maxlength="100" style="background:#ffffff"
             onblur="chkComNm()" value="" />
        </td>
    </tr>
    <tr>
        <td><font color="red">*</font></td>
        <td>用户密码:</td>
        <td>
            <input type="password" name="password" maxlength="20"
             style="background:#ffffff" onblur="chkconfirmPassword()" />
            <div id="confirmPasswordStr" style="background-color:#ff9900;display:none"></div>
        </td>
    </tr>
    </table>
    
    <div align="center">
        <input type="button" name="ok" value=" 确 定 " onclick="checkfield()" />
        <input type="reset" name="reset" value=" 取 消 " />
    </div>
</form>

</body>
</html>

发帖:2006-10-23 13:32:00

本主题贴数9,分页:[返回帖子列表] [上一页] [1] [下一页]

 *树形目录 顶端 
主题:  Ajax问题(386字) - celeron729,2006年10月23日
    回复:  button可以改成submit,这样将导致form提交,越过了原先的参数检查。但是错误不在这里1..(573字) - smzd,2008年9月15日
    回复:  可以是试试微软Asp.Net 提供的Ajax控件(36字) - emyanglin,2008年4月4日
    回复:  恩,还行(7字) - jane_jane,2008年3月14日
    回复:  例子还是不错啊! 有意思! 学习中!(34字) - yanshuihua,2007年11月3日
    回复:  ok.(3字) - celeron729,2006年10月24日
    回复:  楼主还是好好看看Javascript和Ajax的教程吧,Ajax是一种无刷新前后台通信技术,单单一..(96字) - 蓝蔓龙,2006年10月23日
    回复:  以下就是html,都是与该文章相同<%@ page language=&..(6358字) - celeron729,2006年10月23日
    回复:  把HTML大包上来看看。(20字) - Delphi,2006年10月23日

 *快速回复:Ajax问题  [ 回帖是一种美德 :) ]
会员账号 用户名    还没注册?    密码    忘记密码?
内容
  • HTML标签: 不可用
  • UBB标签: 可用
  • 贴图标签: 可用
  • 多媒体标签:可用
  • 表情字符转换:可用
  • 上传图片:不可用
  • 最多15KB
  • 点击表情图即可在帖子中加入相应的表情
                                
    邮件回复 显示签名   [Ctrl+Enter直接提交贴子]