onkeyup="this.value = this.value.replace(/,/g,'.
onkeyup="this.value = this.value.replace(/,/g,'.')" with php echo' '
在输入字段中,需要将,
替换为.
。
有了HTM,这样的代码就可以工作onkeyup="this.value = this.value.replace(/,/g,'.')"
但需要在php中使用(带有echo),如下所示:
echo '<input type="text" name="amount_1" onkeyup="this.value = this.value.replace(/,/g,'.')" style="width:53px;"></input>';
使用php不起作用。如果使用此this.value.replace(/,/g,/./)
,则,
将替换为/./
。
尝试了(/,/g,"/./")
、(/,/g,/"."/)
、(/,/g,.)
,但都不起作用(我的意思是,
不会更改为.
)。
有什么想法吗?
您必须在PHP代码中用反斜杠转义'
。
echo '<input type="text" name="amount_1" onkeyup="this.value = this.value.replace(/,/g,''.'')" style="width:53px;"></input>';
否则,你就把你的绳子剪成图片,然后把它和要点放在一起。
相关文章:
- 将php值传递给点击(getFunction(this.value))问题
- Javascript:this.value 函数不起作用
- Javascript onchange(this.value,this.value)在ipad上不起作用
- this.value在<td>标记显示未定义
- 从javascript insertCell HTML输入标记传递this.value
- 为什么我需要将“var value = val;”更改为“this.value = val;”,这样我就不会收到“未定义
- JQuery 将输入框值设置为 this.value onclick
- this.value 在从 onchange 事件调用函数时显示为 undefind
- 将 this.value 传递给 JS 中的函数,然后更改该值
- 流星:如何使用模板事件检索“{{this}}-value”
- javascript this.value没有'不起作用
- this.value 返回带有值的括号
- AngularJS-将this.value传递到函数中
- 什么是'this.value'经典ASP Javascript参考中的平均值
- onkeyup="this.value = this.value.replace(/,/g,'.
- HTML表单,onclick="this.disabled=true;this.value='发送中,
- JavaScript- this value
- 在requestAnimationFrame中设置正确的this-value
- 如何使用onchange="函数(this.value)
- 通过“this.value"to addEventListener功能