[SOLVED] Regex

This is a discussion on "[SOLVED] Regex" within the JavaScript Forum section. This forum, and the thread "[SOLVED] Regex are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Dec 23rd, 2007, 15:39
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
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>
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote

  #2 (permalink)  
Old Dec 23rd, 2007, 16:46
c010depunkk's Avatar
SuperMember

SuperMember
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to c010depunkk
Re: Regex

Code: Select all
if(str.match(/[A-Z]+/)) {
Reply With Quote
  #3 (permalink)  
Old Dec 23rd, 2007, 16:50
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Regex

No change unfortunately.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #4 (permalink)  
Old Dec 23rd, 2007, 16:52
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Regex

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

<body>
<form action="">
<input type="text" onchange="caps(this.value)" />
</form>
</body>
</html>
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Add white space using RegEx Access JavaScript Forum 2 Feb 8th, 2008 03:30
[SOLVED] playing with Perl Compatible Regex in field validation eon201 JavaScript Forum 33 Oct 26th, 2007 15:07
Adding "Topic Solved" for solved topics AdRock Webforumz Suggestions and Feedback 21 Oct 4th, 2007 15:08
Quick Regex Request Ryan Fait PHP Forum 12 May 29th, 2007 22:54
Regex - Alignment anand1107 JavaScript Forum 1 Mar 21st, 2007 11:32


All times are GMT. The time now is 04:50.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43