Solved

check if value is lower case

Posted on 2008-10-22
11
1,487 Views
Last Modified: 2012-05-05
here's a wierd one.

I need to check if a value is lowercase or not

if(document.move_hdr.sess_user3.value.substring(4,5)== A LOWERCASE LETTER)
alert('that can't be lowercase!)

what code is there to replace 'A LOWERCASE LETTER'
0
Comment
Question by:tampa_vinnie
  • 3
  • 3
  • 2
  • +3
11 Comments
 
LVL 16

Accepted Solution

by:
sh0e earned 250 total points
ID: 22778371

if(document.move_hdr.sess_user3.value.substring(4,5).match(/[a-z]/))
alert('that can't be lowercase!');
 
//or to change it to uppercase
document.move_hdr.sess_user3.value.substring(4,5).toUpperCase();

Open in new window

0
 
LVL 18

Expert Comment

by:Morcalavin
ID: 22778379
Try this.

if(/[^A-Z]/.test(document.move_hdr.sess_user3.value.substring(4,5))
{
//lowercase or not  A - Z(like a ? or ~)
}
else
{
//matches A-Z
}

Open in new window

0
 
LVL 82

Expert Comment

by:hielo
ID: 22778385
if( /[a-z]/.test(document.move_hdr.sess_user3.value.substring(4,5)) )
      alert("that can't be lowercase!");
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22778402



**********what code is there to replace 'A LOWERCASE LETTER'

http://www.w3schools.com/jsref/jsref_toLowerCase.asp
0
 
LVL 82

Expert Comment

by:hielo
ID: 22778419
>>what code is there to replace 'A LOWERCASE LETTER'
OK, then instead of checking for lowercase, just "force" the input into upper case:
var data = String(document.move_hdr.sess_user3.value.substring(4,5)).toUpperCase();
alert( data );
0
 
LVL 82

Expert Comment

by:hielo
ID: 22778437
>>just "force" the input into upper case:
assuming of course you want only upper case. If you simply want to "remove" any lower case then use:
var data = String(document.move_hdr.sess_user3.value.substring(4,5)).replace(/[a-z]/g,'');
alert( data );
0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22778458
var re = /[a-z]/;
      if(!re.test(document.move_hdr.sess_user3.value.substring(4,5)== )) {
       alert('that can't be lowercase!)
0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22778476
additional ==, use the below code

var re = /[a-z]/;
      if(!re.test(document.move_hdr.sess_user3.value.substring(4,5))) {
       alert('that can't be lowercase!)}

Open in new window

0
 

Author Closing Comment

by:tampa_vinnie
ID: 31508821
thorough, accurate and prompt
thanks much!
0
 
LVL 18

Expert Comment

by:Morcalavin
ID: 22778581
@ASPSQLServerCOM
 
 Putting a ! in front of  the test effectively makes it test the opposite, so you are saying "if not lowercase, alert it is lowercase"
0
 
LVL 7

Expert Comment

by:bluV11t
ID: 22778628
alert("That can't be lowercase!");

Just in case you missed it...
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how can i get the string decoded ? 2 28
How to resize a div in html 3 35
jQuery Toggle & Anchor Links 5 43
Filktering Alphabetically 8 29
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question