function check(val) {

var str = val.replace(/(^\s*)|(\s*$)/g, '');//去除空格;
var re = /^[0-9]+.?[0-9]*/; 
if (str.length == 0) {

alert("输入不能为空!")
location.reload(false)
}
else if(str == '' || str == undefined ) {
alert("请输入有效的内容!");
location.reload(false);

}
else if(re.test(str)){
alert(" 输入不能为数字!");
location.reload(false);
}

else if (str.length != 0 || str != '' || str != undefined || !re.test(str)){

var output = document.getElementById("input1").value;
document.getElementById("keyword").value=output;


}
}
Btget.onclick = function () {

check( oTxt1.value );
}

解决方案 »

  1.   

    贴你全部的代码,都不知道 keyword这个在哪
      

  2.   

    你 keyword 是input吗?如果不是你可以用document.getElementById("keyword").innerHTML=output;
      

  3.   

    <!-- #include file="connect.asp" -->
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head><meta http-equiv="Content-Type" content="text/html; charset=gbk" />
    <title>Welcome to UnionPay, the Global Leading Bankcard Association</title>
         <meta name="author" content="m.jd.com">

             <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
                <meta name="apple-mobile-web-app-capable" content="yes">
            <meta name="apple-mobile-web-app-status-bar-style" content="black">
            

       <link rel="stylesheet" type="text/css" href="../css/base2013.css" charset="gbk"/>
    <link rel="alternate icon" type="image/png" href="images/timg.png">

    <link rel="stylesheet" type="text/css" href="../css/2013/category/all_html5.css" charset="gbk"/>

    <link href="css/animate.css" rel="stylesheet" type="text/css" media="all">
             <link rel="apple-touch-icon-precomposed" href="../../m.jd.com/images/apple-touch-icon.png"/>

    </head><body id="body" style=background-image:url('images/bg.jpg')>
    <a name="top"></a>
    <header>

    <br><h2 style="color:white;font-family: 宋体;text-align:center;">查询结果</h2></br>


    </header>
        <form METHOD="POST" ACTION="result.asp">
                   <div id="login_click" style="text-align:center">  
     <form action="result.php" method="post">
     <input type="text" id="input1" style="width:300px;height:25px;font-size:16px;font-family:微软雅黑;"  placeholder="请输入您需要的需求服务类别" list="ide" >
     <input type="submit"  id="btgetword"  style="background:#0072E3; color:#f2f2f2 ;height:28px;width:100px;font-family:宋体;font-weight:bold;border:none" runat="server" value="查询"></div>
    <div id="login_click" style="text-align:center" onclick="getvalue()">
        </form>
     <br><input id="keyword" type="text"  value="" readonly="true" placeholder="正在搜索中....." style="width:400px;height:500px;font-size:16px ;font-family:微软雅黑;" ></br>
    <script type="text/javascript" language="javascript">

    var oTxt1 = document.getElementById('input1'); var Btget = document.getElementById('btgetword');
    var Keyword = document.getElementById('keyword');
    if(document.referrer == "http://localhost:8080/index.asp?"){
    window.onload = function getvalue() 

    var loc = location.href;
    var n1 = loc.length;//地址的总长度
    var n2 = loc.indexOf("=");//取得=号的位置
    var inputkeyword = decodeURI(loc.substr(n2+1, n1-n2));//从=号后面的内容

    document.getElementById("input1").value=inputkeyword;




    }

    if(document.referrer != "http://localhost:8080/index.asp?"){

    function check(val) {

    var str = val.replace(/(^\s*)|(\s*$)/g, '');//去除空格;
    var re = /^[0-9]+.?[0-9]*/; 
    if (str.length == 0) {

    alert("输入不能为空!")
    location.reload(false)
    }
    else if(str == '' || str == undefined ) {
    alert("请输入有效的内容!");
    location.reload(false);

    }
    else if(re.test(str)){
    alert(" 输入不能为数字!");
    location.reload(false);
    }

    else if (str.length != 0 || str != '' || str != undefined || !re.test(str)){

    var output = document.getElementById("input1").value;
    document.getElementById("keyword").value=output;


    }
    }
    Btget.onclick = function () {

    check( oTxt1.value );
    }
    }
    </script>



    </div></div>

        </form>
    </head>
    </html>这是全部的代码