簡體   English   中英

如何從廣播組中刪除Spry驗證?

[英]How can I remove Spry Validation from a Radio Group?

我了解如何破壞文本字段的驗證,但是當我將相同的邏輯應用於單選按鈕組時,Spry驗證不會破壞。

在下面的示例中,您將看到單選按鈕,並且如果用戶選擇“個人”以外的其他選項,則我將在其中破壞驗證。

<script>
var spryradio1;

function checkData(){
    // get the value
    document.getElementById("spryradio1").style.display = "none";
    var value = document.applicationform.type.options[document.applicationform.type.options.selectedIndex].value;
    if(value !=""){
    if(value == "Individual"){

        if(!spryradio1){
        spryradio1 = new Spry.Widget.ValidationRadio("spryradio1");
        }

        document.getElementById("spryradio1").style.display = "block";

    } else {


        // if there is a validaiton in sprytextfield destory it, and clear the variable

        if(spryradio1 && spryradio1.destroy){
            spryradio1.resetClasses();
            spryradio1.destroy();
            spryradio1 = null;
            }

        document.getElementById("spryradio1").style.display = "none";
    }
    // proceed with the rest as normal
    }
    return true;
};
</script>

單選按鈕不喜歡resetClasses行。 當我將行更改為:SpryValidation被破壞時:

if(spryradio1)
{ spryradio1.reset();
spryradio1.destroy();
spryradio1 = null; }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM