Thread: [SOLVED] Regex
View Single Post
  #1 (permalink)  
Old Dec 23rd, 2007, 15:39
alexgeek's Avatar
alexgeek alexgeek is offline
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,801
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Exclamation [SOLVED] Regex

Hi guys,
I want to check the text input to see if it is in all caps.
This needs to be client-side not server side so I'm using JS.
I can't get it to work. My JS skills aren't that bad but I've never used regex with it.

Here's my code.

HTML: Select all
<html>
<head>
<script type="text/javascript">
function caps(str) {
    if(str.test(/[A-Z]+/)) {
    alert("Upper Case");
    }
}
</script>
</head>

<body>
<form action="">
<input type="text" onchange="caps(this)" />
</form>
</body>
</html>
Reply With Quote