for (var i = 0; i <= 20; i++) { var id = "txt" + i var txtbox = document.getElementById(id) if (txtbox) { if (txtbox.value != null && txtbox.value.trim() == "") { alert("Serial Number field cannot be empty"); return false; } }
TextBox
Array
var allTextBoxes = []; $('input[type=text]').each(function () { allTextBoxes.push($(this).val()) }); var sorted_arr = allTextBoxes.sort(); for (var i = 0; i < allTextBoxes.length - 1; i++) { if (sorted_arr[i + 1] == sorted_arr[i]) { alert("Please enter different value in each TextBox."); return false; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)