in my project i have 100 textbox i want to check the every text-box is empty or not
my problem is can i write a short code to check the every textbox is empty or not
my code is so lengthy becoz i check every textbox in if condition
please help me
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jaish MathewsPosted Apr 2, 2010, 1:24 PM
Should approach with JS, as
So you decided to do validation through JavaScrit. Below is one sample. Call this before any postback. I used a regular expression for validating the numeric entry. Remaing all self explanatory.
function validateTextBoxEntries() {
var elements = document.getElementsByTagName("input");
//alert(elements.length);
for (var i = 0; i < elements.length; i++) {
if (elements[i].type.match(/text/)) {
if(elements[i].value == '' || !isNumeric(elements[i].value))
{
alert(elements[i].value + " Invalid");
}
}
}
}
function isNumeric(val) {
var reg = /^ *[0-9]+ *$/;
return reg.test(val);
}
Nikhil MahajanPosted Apr 2, 2010, 7:01 AM
with single for loop it would be checked
Dharmesh SharmaPosted Apr 2, 2010, 2:05 AM
and somthing 200 textbox in the web form how to check the every textbox is empty and enter value is numeric
how to use the control collection
pleas help me........
thanks
Sam HobbsPosted Apr 1, 2010, 2:44 PM
Jaish MathewsPosted Apr 1, 2010, 12:51 PM