Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1495
  • Last Modified:

check if value is lower case

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
tampa_vinnie
Asked:
tampa_vinnie
  • 3
  • 3
  • 2
  • +3
1 Solution
 
sh0eCommented:

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
 
MorcalavinCommented:
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
 
hieloCommented:
if( /[a-z]/.test(document.move_hdr.sess_user3.value.substring(4,5)) )
      alert("that can't be lowercase!");
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ASPSQLServerCOMCommented:



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

http://www.w3schools.com/jsref/jsref_toLowerCase.asp
0
 
hieloCommented:
>>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
 
hieloCommented:
>>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
 
ASPSQLServerCOMCommented:
var re = /[a-z]/;
      if(!re.test(document.move_hdr.sess_user3.value.substring(4,5)== )) {
       alert('that can't be lowercase!)
0
 
ASPSQLServerCOMCommented:
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
 
tampa_vinnieAuthor Commented:
thorough, accurate and prompt
thanks much!
0
 
MorcalavinCommented:
@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
 
bluV11tCommented:
alert("That can't be lowercase!");

Just in case you missed it...
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 3
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now