I want to create a function that will validate a string for improper chars.
As a first try, i tried it on numbers. It Works on IE9, but not on Chrome 12.0.742.122 and Firefox 5 & 6
<html>
<head>
<title>Regex Example</title>
<script type="text/javascript">
var regexp;
var input;
var output;
function replaceChars()
{
regexp = "";
output = "";
input = document.getElementById("myinput").getAttribute("value");
regexp = /\d+/g;
output = input.replace(regexp, "");//Remove Digits
setOutput();
}
function setOutput()
{
document.getElementById("myoutput").setAttribute("value", output);
document.getElementById("myexpr").setAttribute("value", regexp);
document.getElementById("myinput").select();
}
</script>
</head>
<body>
Enter : <input type="text" id="myinput" value="" maxlength="25" size="25"/><br/>
RegEx : <input type="text" id="myexpr" value="" maxlength="25" size="25" readonly /><br/>
Output : <input type="text" id="myoutput" value="" maxlength="25" size="25" readonly />
<input type="button" #nClick="replaceChars();" value="Remove Digits"/>
</body>
</html>