結合JQuery-validate關於數組校驗的問題處理及錯誤信息顯示

function myValidate() {
	var result=true;
	$("input[name='inputname']").each(
	   	function(){
	   		if($(this).val()=="") {
	    		$(this).addClass('my_input_error');
	    		$(this).after('<label class="error"><i class="fa fa-times-circle"></i>  必填</label>');
	    		$(this).focus();
	    		result=false;
	    		return;
	   		}
	 	}
	);
	return result;
}

//移除錯誤樣式
$("input[name='inputname']").keyup(function(){
    $(this).removeClass('my_input_error');
    $(this).next().remove();
});

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章