admin管理员组文章数量:1355594
In input field need to replace ,
with .
.
With HTM such code is working onkeyup="this.value = this.value.replace(/,/g,'.')"
But need to use in php (with echo) like this:
echo '<input type="text" name="amount_1" onkeyup="this.value = this.value.replace(/,/g,'.')" style="width:53px;"></input>';
With php does not work. If use this this.value.replace(/,/g,/./)
then ,
is replaced with /./
.
Tried (/,/g,"/./")
, (/,/g,/"."/)
, (/,/g,.)
nothing works (I mean ,
does not change to .
).
Any ideas?
In input field need to replace ,
with .
.
With HTM such code is working onkeyup="this.value = this.value.replace(/,/g,'.')"
But need to use in php (with echo) like this:
echo '<input type="text" name="amount_1" onkeyup="this.value = this.value.replace(/,/g,'.')" style="width:53px;"></input>';
With php does not work. If use this this.value.replace(/,/g,/./)
then ,
is replaced with /./
.
Tried (/,/g,"/./")
, (/,/g,/"."/)
, (/,/g,.)
nothing works (I mean ,
does not change to .
).
Any ideas?
Share Improve this question edited Jun 23, 2013 at 6:48 user2465936 asked Jun 23, 2013 at 6:44 user2465936user2465936 1,0404 gold badges17 silver badges32 bronze badges 1- What you mean about "does not work"? Errors or something? – Ionică Bizău Commented Jun 23, 2013 at 6:47
1 Answer
Reset to default 6You have to escape the '
with a backslash in your PHP code.
echo '<input type="text" name="amount_1" onkeyup="this.value = this.value.replace(/,/g,\'.\')" style="width:53px;"></input>';
Otherwise you are cuting your string into to pices an put it together with the point.
本文标签:
版权声明:本文标题:javascript - onkeyup="this.value = this.value.replace(,g,'.')" with php echo' ' 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744003252a2574245.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论