国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

javascript - Legal verification of multiple-choice questions
給我你的懷抱
給我你的懷抱 2017-05-16 13:05:06
0
4
739

< /p>

< br>This is a question-answering system. The answer page contains all single-choice questions. I want to verify whether all questions have been selected when the user presses submit. If a question is missed and has not been selected, he cannot be allowed to submit. . . Excuse me, how can I achieve this legal verification using JQ or something else? (Each question in the front-end template is recycled)

給我你的懷抱
給我你的懷抱

reply all(4)
黃舟

jq唄

You always need to generate a submitted json, set the default selection value to -1, bind the click selection to the json data change, and check each option of the json when you click submit to see if there are still objects - 1 is fine

phpcn_u1582

Use jq to verify it when submitting. Just loop through the verification js

為情所困
//遍歷每個(gè)選擇題
var isfinish = true;
$(‘.table’).each(function(){
    //假如沒有填寫
    if($(this).find("input['type'=option]").is('checked')) { // 這句話可能有語法問題,你可以百度一下
        isfinish = false;
        return false;
    }
});
if(isfinish === false) {
    //提示
    return false;
}
為情所困

If they are all single-choice, it stands to reason that you can get the number of selected items and compare them with the number of questions to make a judgment

function checkForm() {
    var q_cnt = ?;//count($data);
    return $("#masterForm input:radio:checked").length == q_cnt;
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template