开发者

How to write the condition to check the validation using jquery or javascript

hello friends,

        $('input[name=checkedRecordsCat]').attr('checked', true);
        $('input[name=checkedRecordsSubCat]').attr('checked', true);
        $('input[na开发者_运维知识库me=checkedRecordsAtta]').attr('checked', true);
        $('input[name=checkedRecordsTextComp]').attr('checked', true);
        $('input[name=checkedRecordsVariableText]').attr('checked', true);
        $('input[name=checkedRecordsFreeFormText]').attr('checked', true);

I have this in my page. i need to check if non of them are checked I need to show a popup message. atleast one check box checked I need do return true.

how to write this condition using jquery or javascript

thanks


Assuming there are no other elements that have a name starting with checkedRecords you can use the starts-with selector combined with the :checked selector

if ( $('input[name^="checkedRecords"]:checked').length ){
   // at least one is checked
   return true;
} else {
   // none is checked
   // show popup here..
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜