I am trying to use the following function to replace all occurens of ' in a input box with ''. The function works for alpha characters but hangs when I use the code below.
function replaceChars(entry) {
out = "\'"; // replace this
add = "\'\'"; // with this
temp = "" + entry; // temporary holder
while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add +
temp.substring((pos + out.length), temp.length));
}
document.subform.text.value = temp;
}
Anyone know how to replace ' with '' using javascript? Thanks.
function replaceChars(entry) {
out = "\'"; // replace this
add = "\'\'"; // with this
temp = "" + entry; // temporary holder
while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add +
temp.substring((pos + out.length), temp.length));
}
document.subform.text.value = temp;
}
Anyone know how to replace ' with '' using javascript? Thanks.