0

I know how to load a dialog box with <a href="alert.html" data-rel="dialog">test</a> what I would like to do is have the dialog box load if any of the form values are blank. This would be triggered/checked when the Next (page15.html) link is clicked. Any suggestion on how to accomplish this?

<a data-role="button" href="page15.html" data-icon="arrow-r" data-iconpos="right">
  Next
</a>
    <form action="#" method="POST">
        <div data-role="fieldcontain" class="no-field-separator">
            <fieldset data-role="controlgroup">
                <label for="textinput2">
                    <span class="c_404040 f_bold">Body Fat Measurements</span>
                </label>
                <input id="textinput2" placeholder="Subsc (mm)" value="" type="number" />
            <br />
                <label for="textinput3">
                </label>
                <input id="textinput3" placeholder="Supra Crest (mm)" value="" type="number" />
            <br />
                <label for="textinput4">
                </label>
                <input id="textinput4" placeholder="Bic (mm)" value="" type="number" />
            <br />
                <label for="textinput5">
                </label>
                <input id="textinput5" placeholder="Tri (mm)" value="" type="number" />
            </fieldset>
        </div>
    </form>
4

1 回答 1

0

这样的事情将是一种方式:

var missingBox = 0;
$('a[href="page15.html"]').click(function(e) {
    e.preventDefault();
    $.each($('form input'),function() {
        if($(this).val() == 0) {
            missingBox += 1;
        } else {
        }
    });
        if(missingBox > 0) {
        console.log('alert');
    }
});
于 2012-05-31T19:21:59.857 回答