[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1498
  • 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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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