Hi @RAVI,
The onkeypress event is deprecated.You can use onchange
Event.
APPLE /45 it has auto correct like this APPLE /45
Didn't see anything that needed to be changed.
MFLOW +/ CURRENT it has to auto corrrect like this MFLOW / CURRENT
Remove the plus sign:\\+
HELLO 'C' it has to correct to HELLO
Do you want to remove the quotes and everything in them?If so, you can use '\\w+\\'
All code
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script>
function myFunction() {
var Regex = new RegExp("'\\w+\\'|\\+");
var word = document.getElementById("TextBox1").value;
console.log(word);
var istr = Regex.test(word);
if (istr) {
alert("Unnecessary Characters! Corrected!")
var a = word.replace(Regex, '');
document.getElementById("TextBox1").value = a;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server" onchange="myFunction()"></asp:TextBox>
</div>
</form>
</body>
</html>
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.