Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

check if value is lower case

Posted on 2008-10-22
11
Medium Priority
?
1,493 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +3
11 Comments
 
LVL 16

Accepted Solution

by:
sh0e earned 1000 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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

722 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