哪裏是錯誤爲什麼DIV不會顯示,我想要做的是檢查的數字是不是空的,值越低,有13jQuery驗證,如果其空,數字或值高於13
JS
(function($) {
if($('#month-holder').length){
$('#month-holder').on("blur", function(e){
e.preventDefault();
var month = $("#month-holder").val();
if (typeof month != "undefined"){
if(!$.isNumeric(month)){
if (parseInt(month) > 13) {
$('#month-error').fadeIn('slow');
$('#month-holder').addClass("invalid");
}
}
}
else
{
$('#month-error').fadeOut('slow');
$('#month-holder').removeClass("invalid");
}
});
}
})(jQuery);
CSS
input.invalid {
border: 1px solid red;
-moz-box-shadow: 0 0 2px 1px #e4e4e4;
-webkit-box-shadow: 0 0 2px 1px #e4e4e4;
box-shadow: 0 0 2px 1px #e4e4e4;
}
#month-error{
display: none;
}
.error{ color: #f00; padding: 5px 0 0}
HTML
<input type="text" name="month-holder" id="month-holder" class="input-txt width-65" placeholder="MM" maxlength="2" pattern="\d*" x-autocompletetype="month-holder" required autocomplete="off">
<div id="month-error" class="error clearfix">Error</div>
任何一個可以幫我請
@Digital注:你測試它? –