TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
CODE CODE
NA
8
5.2k
validation on dropdown inside grid view through javascript
Jul 21 2014 5:24 AM
hello
i need to put validation on dropdown inside gridview ...tyhe validation should check on button click outside the grid
i already use the below code but it doesn't work for a single drop down
<script type="text/javascript">
function validate() {
var flag = true;
var dropdowns = new Array(); //Create array to hold all the dropdown lists.
var gridview = document.getElementById('<%=Grid_acnthead_pstin.ClientID%>'); //GridView1 is the id of ur gridview.
dropdowns = gridview.getElementsByTagName('select'); //Get all dropdown lists contained in GridView1.
for (var i = 0; i < dropdowns.length; i++) {
if (dropdowns.item(i).className == "ddl_budgetgroup" && dropdowns.item(i).value == 'BudgetGroup') //If dropdown has no selected value
// if (dropdowns.item(i).value == 'BudgetGroup') //If dropdown has no selected value
{
flag = false;
break; //break the loop as there is no need to check further.
}
}
if (!flag) {
alert('Please select value in each dropdown');
}
return flag;
}
</script>
actually mry my gridview has 4 column and all the four column contains dropdown.. and i have to put validation for all the 4 dropdowns..
please give me any idea how to access it
Thanks in adveance :)
Reply
Answers (
0
)
Script Add automatically database table field
How can I do this for DropDownList in MVC5?