验证li选择

时间:2013-06-03 13:40:27

标签: php jquery html validation

我在ImagePicker plugin旁边有一个使用Janko At Warpseeds Form to Wizard插件的表单,我想确保在单击Next之前选择所有图像。

我目前正在使用Bassassistance验证插件。

有没有人知道如何实现这个目标?

JSFiddle显示当前的工作代码和所有javascript http://jsfiddle.net/4Hkxy/

    $(function () {
       jQuery(function($){
            var $signupForm = $( '#multipage' );
 $signupForm.formToWizard({
                submitButton: 'SaveAccount',
                showProgress: true, //default value for showProgress is also true
                nextBtnName: 'Forward >>',
                prevBtnName: '<< Previous',
                showStepNo: false,
                validateBeforeNext: function() {
                    var selectedCount = $('.thumbnails.image_picker_selector:visible .selected').length;
    var totalCount = $('.thumbnails.image_picker_selector:visible').length;

    if(selectedCount != totalCount) {
        alert('please select an image per selection');
    }
                }
            });
});

    $("select.image-picker").imagepicker({
        hide_select: true,
        show_label: true,
    });
    $("select.image-picker.show-labels").imagepicker({
        hide_select: true,
        show_label: true,
    });

    var container = $("select.image-picker.masonry").next("ul.thumbnails");
    container.imagesLoaded(function () {
        container.masonry({
            itemSelector: "li",
        });
    });

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:0)

试试这个:

    //inside "next.onclick" handler
    var selectedCount = $('.thumbnails.image_picker_selector:visible .selected').length;
    var totalCount = $('.thumbnails.image_picker_selector:visible').length;

    if(selectedCount != totalCount) {
        alert('please select an image per selection');
    }