JS部分
View Code
function submit(){ //最后点购买的判断! var a = $("#rmb").val(); var b = $("input:checkbox").attr("checked"); if(b !== 'checked'){ alert('请阅读协议并同意!'); return false; }else if(!a || isNaN(a)){ //isNAN()是JQUERY里的一个判断是否为非数字的函数 本句 是“ 如果 非a 或者a不是数字” alert('请输入数字!'); return false; } //$("#form1").submit(); } function costview(num){ //输入金额以后的判断! if(isNaN(num)){ alert('请输入数字!'); return false; } $("#rmb").val(num); //取INPUT的VALUE用JQUERY 的VAL $('#SpanPayAmount').html(num);//取INPUT的输入内容用HTML } function clearrmb(a){ //clearrmb();传入参数a,输入数字的那个onclick上调用的clearrmb的a==1,其他的a为空。 if(a == 1){ $("#SpanPayAmount").removeAttr("disabled"); return;//选中radio的时候去掉disabled="disabled"并且返回,否则使输入值为0 } $("#SpanPayAmount").val(0); //没有选中radio的时候清零 $("#SpanPayAmount").attr("disabled","disabled");//将disabled设置为disabled 即.attr("disabled",true);这样写也可以 }
HTMl部分
<form action="/shop/pay" method="post" accept-charset="utf-8" id="form1"> <input type='hidden' value="10" id="rmb"> </form> <table cellspacing="0" cellpadding="0" class="section_table01" id="tableFirst" width="760"> <tbody> <tr style="display: none" id="trGroup"> <td>兑换COIN:</td> </tr> <tr id="trMoney"> <td> <span id="AmountRadio" style="margin:0; padding:0;"> <input class="cradio" type="radio" value="10" name="radioamount" onclick="clearrmb();costview(this.value)" checked="checked"> 10 Coin <input class="cradio" type="radio" value="30" name="radioamount" onclick="clearrmb();costview(this.value)"> 30 Coin <input class="cradio" type="radio" value="50" name="radioamount" onclick="clearrmb();costview(this.value)"> 50 Coin <input class="cradio" type="radio" value="100" name="radioamount" onclick="clearrmb();costview(this.value)"> 100 Coin <input class="cradio" type="radio" value="0" name="radioamount" onclick="clearrmb(1);costview(this.value);"> </span> <div style="display: inline;" id="DivMoney"><input type="text" id="SpanPayAmount" style="40px; color:#000;" value='0' disabled="disabled" class="easyui-numberbox" data-options="min:1,max:10000,precision:0,required:true"> Coin</div> <br> </td> </tr> <tr id="TrPayAmount"> <td height="30" align="center" class="larg_txt"> <span class="b_txt">需要支付RMB:</span><span id="SpanPayAmount" class="highlight_txt">10</span><span class="highlight_txt">元</span> </td> </tr> </tbody> </table> </div> <div class="lindotted"></div> <table width="760" border="0" cellspacing="0" cellpadding="0"> <tr> <td><input name=" " type="radio" value="" class="alipayradio"/><img src="/themes/tekken2/images/alipay.jpg" width="115" height="51" /></td> </tr> <tr> <td> <button onclick="submit()" name="conform" class="coin-props-buy1" value=""></button> <input type="checkbox" value="checkbox" class="zt1" name="checkbox" onclick="open1()"> <span class="zt2">我同意该协议</span> <span class="zt3">(购买前先查看<a onclick="open1()">商城协议</a>)</span> <div class="simple_overlay" title="商城协议" id="mies1" closeable="true" closed="true" resizable="false" modal="true" overflow="auto" style="720px; height:320px;" shadow="false" >协议内容<p class="esbtn" align="center"><a class="easyui-linkbutton" onclick="close1()">关闭</a></p> </div> </td> </tr> </table> </div>