Вопрос

I have this phone validation form http://jsfiddle.net/hEj3R/ used to make sure the user are posting his own cellphone when register a new account.

My problem is how to 'not validate' the form when the user click 'prev' button.

Please help.

Thanks a lot.

Here is the code:

HTML:

<form accept-charset="UTF-8" id="form1" method="post" action="register" enctype="multipart/form-data"><div><div id="pg-reg">
    <fieldset> 
      <div class="ui-form-item">
        <label class="ui-label">Phone</label>
        <label class="input-icon form-text">13366669999</label>
      </div>
      <div class="ui-form-item"> 
        <label class="ui-label">Code</label> 
        <input type="text" class="ui-input input-icon form-text valid" id="edit-vcode" name="vcode" value="">
        <span class="icon input-icon-lock"></span> 
      </div> 
      <div class="ui-form-item"> 
        <input type="submit" value="Prev" name="prev" id="edit-prev" class="ui-button ui-button-blue ui-button-mid form-submit"><input type="submit" value="Finish" name="op" id="edit-finish" class="ui-button ui-button-blue ui-button-mid form-submit">          </div>
              </fieldset>
</form>

JS:

$("#form1").validate({
            rules: {
                vcode: {
                    required: true,
                },
            },
            messages: {
                vcode: {
                    required: "Please input the validation code you received",
                },
            }
        });
Это было полезно?

Решение

Simply change the type of the 'Prev' button to:

type="button"

Check out updated fiddle and How to prevent buttons from submitting forms

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top