简体   繁体   English

验证表单替换文本textarea

[英]Validate form replace text textarea

I have a validation form checker - when my checkbox has the value of 1 - i want to replace some text in the TextArea with new Text. 我有一个验证表单检查器-当我的复选框的值为1时-我想用新的Text替换TextArea中的一些文本。 Does anyone know the correct code to do this? 有人知道执行此操作的正确代码吗?

everything else in the form checker works, except this one. 除了这一点以外,表单检查器中的其他所有内容均有效。

function validateForm(myForm){
if (getRadioSelected(myForm.myCheckBox) == 1) {
myForm.myTextArea.value.replace("Old Text","Replacement Text");
}
}
var newString = myForm.myTextArea.value.replace("Old Text","Replacement Text");
myForm.myTextArea.value = newString;

The replace method returns a string but doesn't set your textarea value. replace方法返回一个字符串,但未设置您的textarea值。 This does. 确实如此。

- edit - - 编辑 -

jsFiddle in action ! jsFiddle 在行动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM