2014年7月13日 星期日

[RESOLVED] Javascript validation for radio buttons in repeater control


I have a repeater control for feedback




Code is

























FeedBack









Select an item













Now i need javascript validate so that user selects answer for all the questions.





Hi,


Please refer the thread which maybe helpful to you


http://forums.asp.net/t/1537904.aspx/1


http://www.encodedna.com/2013/02/aspdotnet.gridview-row-jquery.htm


Hope it can help you



Assume your repeater is wrapped into some div with id="surveyContainer" and every item template in repeater is wrapped in div with class="survey-question":


function isValid(){
var countQuestions = $(".survey-question").length;
var countChecked = $(":checked", $("#surveyContainer")).length;
return countQuestions == countChecked;
}

If you have checkboxes or select elements somewhere in a page - change the selector to be more strict


$("[type=radio]:checked")






沒有留言:

張貼留言