使用js拼一个变量

博客展示了一个包含价格输入框和检查按钮的表单。使用JavaScript编写了去除逗号的函数GetOutOffComma,以及用于检查输入是否符合规则的函数checkColor,可判断输入是否为合法数字。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<form name="rfqRespondForm">
价格一<input type="text" name="prod_price0"><br>
价格一<input type="text" name="prod_price1"><br>
价格一<input type="text" name="prod_price2"><br>
<input type="button" value="check" onclick="checkColor('color')">
检查一下时候是数字 1,000.00为合法

<script language="JavaScript">
//this function is to get off all the comma
function GetOutOffComma(str){
 re = /,/gi;
 newstr=str.replace(re, "");
 return newstr;
}

//this function judge the regular expression if the current input is not obey the rule then we return false ,then focus and select it
function checkColor(object)
{

 for(i=0;i<3;i++){
  alert(i+"-----------------");
  alert("---------------------"+"prod_price"+i+"");
  alert(document.all["prod_price"+i+""].value);
  //alert(i+"---------------"+document."prod_price"+i+"".value);
 }
 
}
</script>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值