$(document).ready(function () { var str = 'Test'; //alert(str.to...">

Help with $ (this) .val () toUpperCase ()

Given:

<script type="text/javascript"> $(document).ready(function () { var str = 'Test'; //alert(str.toUpperCase()); $('#stringFinder').keyup(function (e) { alert($(this).val()==str.toUpperCase()); }); }); </script> 

How do I make $ (this) .val () all uppercase to get a similar comparison using?

Thanks rodchar

+4
source share
3 answers

$(this).val() returns a String object , which means that you are executing String methods , like this:

alert($(this).val().toUpperCase() === str.toUpperCase());

+13
source
  $('#stringFinder').keyup(function (e) { alert($(this).val().toUpperCase() == str.toUpperCase()); }); 
+6
source

Try the following:

  $(".solomayus").keypress(function (event) { $(this).val($(this).val().toUpperCase()); }); 

OR

  $('.solomayus').blur(function () { $(this).val($(this).val().toUpperCase()); }); 
+2
source

Source: https://habr.com/ru/post/1309454/


All Articles