0

양식에 jQuery 도구 (http://flowplayer.org/tools/demos/index.html) 유효성 검사기를 사용하고 있으며 드롭 다운 및 라디오 버튼의 유효성을 검사하는 방법이 궁금하십니까?드롭 다운 상자/라디오 버튼 유효성 검사?

누구나 그것을 구현 한 경험이 있습니까?

+0

명확한 예를 들어이있는 [문서]의 체크 박스 [(http://flowplayer.org/tools/demos/validator/events의 유효성을 확인하는 .html) 지금까지 무엇을 했습니까? 더 나은 결과를 위해 결과 (코드)를 표시하십시오 – ifaour

+0

죄송합니다, 오타가 확인란을 원하지 않았습니다 ... 드롭 다운 및 라디오 버튼에서 작동해야합니다! –

답변

0

문서에서 SELECT 요소에 required = "required"속성을 사용할 수도 있지만 나에게도 해당되지 않는다고 말합니다. 맞춤 검사기 기능을 사용하기로 선택했습니다. 희망이 당신을 위해 작동합니다. 그것은 매우 기본이지만, 더 유연하게 만드는 다른 고려 사항이 없습니다.

$.tools.validator.fn("select[required=required]", function(input, value) { 
    // If the first item in the list is selected return FALSE 
    return !input[0].options[0].selected; 
}); 
+0

어디에서 추가해야합니까? –

1

그냥과 같이 추가 :

<script type="text/javascript"> 
$(document).ready(function(){ 
    // initialize validator and supply the onBeforeValidate event in configuration 

$("#GetAQuote").validator({ 
    position: 'top left', 
    offset: [-5, 25], 
    message: '<div><em/><img src="images/form-error.gif" style="float:right;"/></div>'  
    // em element is the arrow 
}); 

$.tools.validator.fn("select[required=required]", function(input, value) { 
    // If the first item in the list is selected return FALSE 
    return !input[0].options[0].selected; 
}); 


$("#GetAQuote").bind("onFail", function(e, errors) { 

// we are only doing stuff when the form is submitted 
if (e.originalEvent.type == 'submit') { 

    // loop through Error objects and add the border color 
    $.each(errors, function() { 
     var input = this.input; 
     input.css({borderColor: '#e6a200'}).focus(function() { 
      input.css({borderColor: '#75a9cc'}); 
     }); 
    }); 
    } 
    }); 
}); 
</script>