Wednesday, February 3, 2010

Javascript RegEx - to check whether a string contain numeric value or not.

<script type="text/javascript">
//matches any non-digit in string
var patt1=/\D/;

document.write(patt1.test(""));
document.write("\n");
document.write(patt1.test("@"));
document.write("\n");
document.write(patt1.test("A"));
document.write("\n");
document.write(patt1.test("AAA"));
document.write("\n");
document.write(patt1.test("1"));
document.write("\n");
document.write(patt1.test("111"));
document.write("\n");
document.write(patt1.test("AA111"));
document.write("\n");
</script>
</body>
</html>

Try It
More Regex Patterns

No comments:

Post a Comment