你好,我想些一个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>
<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>
<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>
var account2=document.getElementById('txt_raccount);
if(account1.value==account2.value)
alert('相同');
else
alert('不相同');
<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>这是全部代码,好像不能实现
</tr>
<tr>
<th align="right">* 重复输入账户 </th>
<td> <input name="txt_raccount" id="txt_raccount2" size="60" value="" type="text"/> </font> </td> input设置type属性,好像还有其他需要改的地方,请指教
<th align="right">* 重复输入账户 </th>
<td> <input name="txt_raccount" id="txt_raccount2" size="60" value="" type="text"/> </font> </td>红字处笔误,应该是txt_account2做程序,要细心
<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如何关联
如果两次输入的账号一致,那怎么降这个账号一同传给下一个页面啊?
请指教,谢谢
<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>
这个意思吗?
<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>
再试一试看看
<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>
阻止黏贴
<head>
<title>test</title>
</head>
<body>
<input id="0" />
<input id="1" onpaste="return false" />
</body>
</html>
script language="javascript">
var text1=document.getElementById('txt_account1').value;//得到文本框1的值
var text2=document.getElementById('txt_account2').value;//得到文本框2的值
if(text1 != text2)
alert("两个值不相等");
</script>
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>
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>