你好,我想些一个javascript,判断两次输入的账号一致,该如何做啊?
     <tr>
  <th width="18%" align="right">* 需要充值的账户</th>
  <td width="82%"><input name="txt_account" id="txt_account" size="60" value="" /></td>
</tr>
<tr>
  <th align="right">* 重复输入账户</th>
  <td><input name="txt_raccount" id="txt_raccount" size="60" value="" /></font></td>
</tr>
<tr>
<th></th>
<td height="50">
<input type="submit" name="sb_next" class="paysubmit" value="发送"  /></td>
</tr>

解决方案 »

  1.   

    <tr> 
      <th width="18%" align="right">* 需要充值的账户 </th> 
      <td width="82%"> <input name="txt_account" id="txt_account1" size="60" value="" /> </td> 
    </tr> 
    <tr> 
      <th align="right">* 重复输入账户 </th> 
      <td> <input name="txt_raccount" id="txt_raccount2" size="60" value="" /> </font> </td> 
    </tr> 
    <tr> 
    <th> </th> 
    <td height="50"> 
    <input type="submit" name="sb_next" class="paysubmit" value="发送" onclick="test()"  /> </td> 
    </tr><script language="javascript">
    var text1=document.getElementById('txt_account1').value;//得到文本框1的值
    var text2=document.getElementById('txt_account2').value;//得到文本框2的值
    if(text1 != text2)
     alert("两个值不相等");
    </script>
      

  2.   

    var account1=document.getElementById('txt_account');
    var account2=document.getElementById('txt_raccount);
    if(account1.value==account2.value)
      alert('相同');
    else
      alert('不相同');
      

  3.   

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>网易</title><script language="javascript"> 
    var text1=document.getElementById('txt_account1').value;//得到文本框1的值 
    var text2=document.getElementById('txt_account2').value;//得到文本框2的值 
    if(text1 != text2) 
    alert("两个值不相等"); 
    </script></head>
    <body>
    <form action="xxxx" id="netease" method="post">     
       <table width="100%" cellpadding="0" cellspacing="10">

        <tr> 
      <th width="18%" align="right">* 需要充值的账户 </th> 
      <td width="82%"> <input name="txt_account" id="txt_account1" size="60" value="" /> </td> 
    </tr> 
    <tr> 
      <th align="right">* 重复输入账户 </th> 
      <td> <input name="txt_raccount" id="txt_raccount2" size="60" value="" /> </font> </td> 
    </tr> 
    <tr> 
    <th> </th> 
    <td height="50"> 
    <input type="submit" name="sb_next" class="paysubmit" value="发送" onclick="test()"  /> </td> 
    </tr>
    </table>
    </form>
       
    </body>
    </html>这是全部代码,好像不能实现
      

  4.   

      <td width="82%"> <input name="txt_account" id="txt_account1" size="60" value=""  type="text"/> </td> 
    </tr> 
    <tr> 
      <th align="right">* 重复输入账户 </th> 
      <td> <input name="txt_raccount" id="txt_raccount2" size="60" value="" type="text"/> </font> </td> input设置type属性,好像还有其他需要改的地方,请指教
      

  5.   

    onclick=test()你的test方法在哪?
      

  6.   

    另外<tr> 
      <th align="right">* 重复输入账户 </th> 
      <td> <input name="txt_raccount" id="txt_raccount2" size="60" value="" type="text"/> </font> </td>红字处笔误,应该是txt_account2做程序,要细心
      

  7.   

    恩,谢谢,我就是不知道test()这个方法与
    <script language="javascript"> 
    var text1=document.getElementById('txt_account1').value;//得到文本框1的值 
    var text2=document.getElementById('txt_account2').value;//得到文本框2的值 
    if(text1 != text2) 
    alert("两个值不相等"); 
    </script> 
    这个javascript如何关联
      

  8.   

    当我点击发送的时候(或者两个账户输入不一样,就是点击发送按钮之前页面如何提示两个输入的账号不一样啊?),如何判断两次输入的账号是否一致,这个test()方法与上面javascript如何关联才好啊? 
    如果两次输入的账号一致,那怎么降这个账号一同传给下一个页面啊?
    请指教,谢谢
      

  9.   

    <html>
    <head>
    <script type="text/javascript">
    function testCount(){
    var count1 = document.getElementById("txt_account");
    var count2 = document.getElementById("txt_raccount");
    if(count1!=count2){
    alert("不一致");
    }else{
    with(document.getElementById("form1")){
    method="post";
    action="你的URL";
    submit();
    }
    }
    }
    </script>
    </head>
    <body>
    <form id="form1">
    <tr>
      <th width="18%" align="right">* 需要充值的账户 </th>
      <td width="82%"> <input name="txt_account" id="txt_account" size="60" value="" /> </td>
    </tr>
    <tr>
      <th align="right">* 重复输入账户 </th>
      <td> <input name="txt_raccount" id="txt_raccount" size="60" value="" /> </font> </td>
    </tr>
    <tr>
    <th> </th>
    <td height="50">
    <input type="button" name="sb_next" class="paysubmit" value="发送" onclick='testCount()' /> </td>
    </tr>
    </body>
    </html>
    这个意思吗?
      

  10.   


    <html> 
    <head> 
    <script type="text/javascript"> 
    function testCount(){ 
    var count1 = document.getElementById("txt_account").value; 
    var count2 = document.getElementById("txt_raccount").value; 
    if(count1!=count2){ 
    alert("不一致"); 
    }else{ 
    with(document.getElementById("form1")){ 
    method="post"; 
    action="你的URL"; 
    submit(); 



    </script> 
    </head> 
    <body> 
    <form id="form1"> 
    <tr> 
      <th width="18%" align="right">* 需要充值的账户 </th> 
      <td width="82%"> <input name="txt_account" id="txt_account" size="60" value="" /> </td> 
    </tr> 
    <tr> 
      <th align="right">* 重复输入账户 </th> 
      <td> <input name="txt_raccount" id="txt_raccount" size="60" value="" /> </font> </td> 
    </tr> 
    <tr> 
    <th> </th> 
    <td height="50"> 
    <input type="button" name="sb_next" class="paysubmit" value="发送" onclick='testCount()' /> </td> 
    </tr> 
    </body> 
    </html> 
    再试一试看看
      

  11.   

    我上面那个忘记写VALUE了。。
    <th align="right">* 重复输入账户 </th>
      <td> <input name="txt_raccount" id="txt_raccount" size="60" value="" onpaste='return false' oncontextmenu='return fasle' onkeypress="return !(event.ctrlKey&&(String.fromCharCode(event.charCode=='v')))"/> </font> </td>
    阻止黏贴
      

  12.   

    <html>
    <head>
    <title>test</title>
    </head>
    <body>
    <input id="0" />
    <input id="1" onpaste="return false" />
    </body>
    </html>
      

  13.   


    script language="javascript"> 
    var text1=document.getElementById('txt_account1').value;//得到文本框1的值 
    var text2=document.getElementById('txt_account2').value;//得到文本框2的值 
    if(text1 != text2) 
    alert("两个值不相等"); 
    </script>
      

  14.   

    谢谢大家啊,还有一个问题,呵呵,下列代码中 我想让product_id对应的charge通过下面的加密函数加密之后传到abs.asp,但是结果不是加密传的,而是直接post传的<?php
    switch($product_id){
    case '20302000':
    $charge = 1800;
    break;
    case '20301000':
    $charge = 1000;
    break;
    }
    $EncodingTxt = calling($product_id,$charge);
    function calling($product_id,$charge) {
    $EncodingValue = "";
    $EncodingValue = "product_id=". $product_id .";charge=". $charge;

    $EncodingTxt = Encoding($EncodingValue);
    return $EncodingTxt;
    }
    function Encoding($EncodingValue){
    $cmd = sprintf("jiami.exe W E \"%s\" ", $EncodingValue); 
    $EncodingTxt = exec($cmd);
    return $EncodingTxt;
    }
    ?>
    <html>
    <head>
    <title>***</title>
    <script type="text/javascript"> 
    function testCount(){ 
    var count1 = document.getElementById("txt_account").value; 
    var count2 = document.getElementById("txt_raccount").value; 
    if(count1!=count2){ 
    alert("输入的账号不一致,请重新输入"); 
    }else{ 
    with(document.getElementById("form1")){ 
    method="post"; 
    action="http://***/abs.asp"; 
    submit(); 



    </script> 
    </head>
    <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" onLoad="document.requestfrm.telnumber2.focus();SelCountry(document.requestfrm.area);">
    <form id="form1"> 
    <table width="374" height="415" border="0" align="center" cellpadding="0" cellspacing="1" style="border:1px solid #000000;">

    <tr>
      <td width="35%" align="center" height="50" valign="center"><font size="2.5px" color="#008000">* 充值金额</font></td>
      <td width="65%" valign="bottom" height="50"><label>
    <input type="radio" name="product_id" id="product_id" value="20302000" checked /><font size="2.5px">网易一卡通18元100点(18元)</font></label>
    <br />
    <label>
        <input type="radio" name="product_id" id="product_id" value="20301000"  />网易一卡通10元60点</label>
    <br /><label> </td>
    </tr>

    <tr> 
      <td width="35%" align="center" height="50"><font size="2.5px" color="#008000"> * 需要充值的账户</font> </td> 
      <td width="65%" align="center" height="50"> <input name="txt_account" id="txt_account" size="25" value="" /> </td> 
    </tr> 
    <tr>    <td align="center"><font size="2.5px" color="#008000">* 重复输入账户</font> </td> 
      <td align="center"> <input name="txt_raccount" id="txt_raccount" size="25" value="" onpaste='return false' oncontextmenu='return fasle' 
                           onkeypress="return!(event.ctrlKey&&(String.fromCharCode(event.charCode=='v')))"/> </font> </td> 
    </tr> 
    <tr> 
    <td height="50" colspan="2" align="center"> 
    <input type="button" name="sb_next" class="paysubmit" value="发送" onclick='testCount()' /> </td>
    <INPUT TYPE="hidden" NAME="request" VALUE="<? echo($EncodingTxt) ?>">
    </tr> 
       
                  </table>
      

  15.   

    1. 我想问下面代码中switch($product_id) 这里product_id与 <input type="radio" name="product_id" id="product_id" 代码中的product_id是否是同一个 
    2.我想按照switch语句,当用户选择不同的产品时,根据product_id的value来传相对应的charge,就是product_id与charge按照下面代码中的函数处理,就是拼成串之后用加密工具进行加密,然后传过去,但我用echo $EncodingTxt;exit; 这个语句却不能显示 EncodingTxt的值,难道是函数处理过程中出了问题还是switch中的$product_id 与下面的 <input type="radio" name="product_id" id="product_id"  这里的product_id不一样导致不输出。 
    <?php 
    switch($product_id){ 
    case '20302000': 
    $charge = 1800; 
    break; 
    case '20301000': 
    $charge = 1000; 
    break; 

    $EncodingTxt = calling($product_id,$charge); 
    function calling($product_id,$charge) { 
    $EncodingValue = ""; 
    $EncodingValue = "product_id=". $product_id .";charge=". $charge; $EncodingTxt = Encoding($EncodingValue); 
    return $EncodingTxt; 

    function Encoding($EncodingValue){ 
    $cmd = sprintf("jiami.exe W E \"%s\" ", $EncodingValue); 
    $EncodingTxt = exec($cmd); 
    return $EncodingTxt; 
    } echo $EncodingTxt;exit; 
    ?> 
    <html> 
    <head> 
    <title>*** </title> 
    <script type="text/javascript"> 
    function testCount(){ 
    var count1 = document.getElementById("txt_account").value; 
    var count2 = document.getElementById("txt_raccount").value; 
    if(count1!=count2){ 
    alert("输入的账号不一致,请重新输入"); 
    }else{ 
    with(document.getElementById("form1")){ 
    method="post"; 
    action="http://***/abs.asp"; 
    submit(); 



    </script> 
    </head> 
    <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" onLoad="document.requestfrm.telnumber2.focus();SelCountry(document.requestfrm.area);"> 
    <form id="form1"> 
    <table width="374" height="415" border="0" align="center" cellpadding="0" cellspacing="1" style="border:1px solid #000000;"> <tr> 
      <td width="35%" align="center" height="50" valign="center"> <font size="2.5px" color="#008000">* 充值金额 </font> </td> 
      <td width="65%" valign="bottom" height="50"> <label> 
    <input type="radio" name="product_id" id="product_id" value="20302000" checked /> <font size="2.5px">网易一卡通18元100点(18元) </font> </label> 
    <br /> 
    <label> 
        <input type="radio" name="product_id" id="product_id" value="20301000"  />网易一卡通10元60点 </label> 
    <br /> <label> </td> 
    </tr> <tr> 
      <td width="35%" align="center" height="50"> <font size="2.5px" color="#008000"> * 需要充值的账户 </font> </td> 
      <td width="65%" align="center" height="50"> <input name="txt_account" id="txt_account" size="25" value="" /> </td> 
    </tr> 
    <tr>   <td align="center"> <font size="2.5px" color="#008000">* 重复输入账户 </font> </td> 
      <td align="center"> <input name="txt_raccount" id="txt_raccount" size="25" value="" onpaste='return false' oncontextmenu='return fasle' 
                          onkeypress="return!(event.ctrlKey&&(String.fromCharCode(event.charCode=='v')))"/> </font> </td> 
    </tr> 
    <tr> 
    <td height="50" colspan="2" align="center"> 
    <input type="button" name="sb_next" class="paysubmit" value="发送" onclick='testCount()' /> </td> 
    <INPUT TYPE="hidden" NAME="request" VALUE=" <? echo($EncodingTxt) ?>"> 
    </tr> 
      
                  </table> 
      

  16.   

    我在代码的最前面加上  $product_id = $_POST['product_id']; 这个的话,能获得 <input type="radio" name="product_id" id="product_id" 这里的value值么? 貌似不行,因为form1里会post传到abs.asp页面里,但是我想在本页面中获得 <input type="radio" name="product_id" id="product_id" 这里的value(然后找到相应的product_id的charge),然后将相关product_id与charge,一同进行上面的函数处理之后传到abs.asp页面(即点击发送按钮之后跳转到的下一页)