0

I am trying to make a jquery script that checks the first 4 characters of a textbox input against an array. But i need to convert that textbox input into uppercase characters and then check it against the array.

Live Example: http://jsfiddle.net/24Mqw/3/

$(document).ready(function () {
var namess = ['BT', 'IM1', 'IM2', 'IM3', 'IM4', 'IM5', 'IM6', 'IM7', 'IM8', 'IM9', 'TR21', 'TR22', 'TR23', 'TR24', 'TR25', 'PO30', 'PO31', 'PO32', 'PO33', 'PO34', 'PO35', 'PO36', 'PO37', 'PO38', 'PO39', 'PO40', 'PO41', 'AB30', 'AB31', 'AB33', 'AB34', 'AB35', 'AB36', 'AB37', 'AB38', 'AB43', 'AB44', 'AB45', 'AB46', 'AB47', 'AB48', 'AB49', 'AB50', 'AB51', 'AB52'];

$(".Quantity").bind("blur", function () {
    var names = $(this).val().toUpperCase().substring(0, 4).up;
    if (jQuery.inArray(names, namess) != '-1') {

        $('.Quantity').val('');

        $('#dialogBadOrder').jqm({
            overlay: 50,
            modal: true
        });

        $('#dialogBadOrder').jqmShow();

    }
});

})

Thanks in advance.

jagmitg
  • 2,101
  • 2
  • 18
  • 32

2 Answers2

2

Correct code:

var names = $(this).val().toUpperCase().substring(0, 4);

// remove .up from your code

Irfan DANISH
  • 7,957
  • 12
  • 39
  • 66
0

Try something like this

$(this).val($(this).val().toUpperCase());
var names = $(this).val().substring(0, 4);
MKB
  • 7,475
  • 9
  • 42
  • 70
rajesh kakawat
  • 10,698
  • 1
  • 20
  • 39