JSFiddle - React, Tailwind, and code Playground
HTML
<asp:TextBox id="txtInput" runat="server" />
<asp:Button id="btnSubmit" runat="server" Text=
"Submit" onclientclick="return validateString();"/>
JavaScript
function validateString()
{
var regex = /^[a-zA-Z ]*$/;
if(regex.test((document.getElementById("txtInput").value)))
{
alert("input string is correct");
}
else
{
alert("Only string is allowed here");
return false;
}
}