Solved

check if value is lower case

Posted on 2008-10-22
11
1,485 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now