Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Case-insensitive switch-case

OK, so let's say I have this:

$(function() {
  $('#good_evening').keyup(function () {
    switch($(this).val()) {
    case 'Test':
      // DO STUFF HERE
      break;
    }
  });
});

... this would only run if you typed "Test" and not "test" or "TEST". How do I make it case-insensitive for JavaScript functions?

like image 566
test Avatar asked Sep 11 '10 07:09

test


1 Answers

switch($(this).val().toLowerCase()) {
    case 'test':
    // DO STUFF HERE          
    break;
}
like image 130
Matt Briggs Avatar answered Oct 27 '22 12:10

Matt Briggs