onclick of Replace button it will call the javascript(repll)
function repll() {
var findt = document.getElementById('findtext').value.trim();
var findin = document.getElementById('TextBox1').value.trim();
var findrep = document.getElementById('replace').value.trim();
var findIndex = findin.indexOf(findt, indexsta);
var charLength = findt.length;
if (findIndex > 0) {
indexsta = findIndex;
findin = setCharAt(findin, indexsta, findrep);
}
}
function setCharAt(findin, index, chr) {
if (index > findin.length - 1) return findin;
var replacethetext = findin.substr(0, index) + chr + findin.substr(index + 1);
document.getElementById('TextBox1').value = replacethetext;
return replacethetext;
}
<asp:TextBox ID="TextBox1" Text="testing the find and replace function .testing :P"
runat="server" Width="417px"></asp:TextBox>
<asp:TextBox ID="findtext" runat="server"></asp:TextBox>
<asp:TextBox ID="replace" runat="server"></asp:TextBox>
<input type="button" id="btnrep" value="Replace" onclick="repll()" />
Sahoo, if this helps please login to Mark As Answer. | Alert Moderator