Solved

check if value is lower case

Posted on 2008-10-22
11
1,483 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
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…

760 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

20 Experts available now in Live!

Get 1:1 Help Now