Reputation: 15455
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 upper case to get a like comparison using contains?
Thanks, rodchar
Upvotes: 5
Views: 38001
Reputation: 21
Try this:
$(".solomayus").keypress(function (event) {
$(this).val($(this).val().toUpperCase());
});
OR
$('.solomayus').blur(function () {
$(this).val($(this).val().toUpperCase());
});
Upvotes: 2
Reputation: 35409
$('#stringFinder').keyup(function (e) {
alert($(this).val().toUpperCase() == str.toUpperCase());
});
Upvotes: 6
Reputation: 342635
$(this).val()
returns a String object, which means you perform any String methods on it, so:
alert($(this).val().toUpperCase() === str.toUpperCase());
Upvotes: 15