初心者です。
Wordpressに「jQuery-steps」を利用したページを作成したいのですが、
必須チェックがうまくいきません。
実現したいことは、STEPごとにそれぞれ説明文を記載し、「確認しました」のチェックボックスにチェックを入れないと、エラー表示が出て次のSTEP画面に進めないようにしたいです。
(4STEP目でチェックボックスにチェックを入れて「Finish!」を押すと別ページに飛びます)
▼ jQuery steps
http://www.jquery-steps.com/Examples
header.phpに
<jquery.steps.css>
<normalize.css>
<main.css>
<jquery.steps.min.js>
を読み込むソースコードを入れています。
HTML
<div id="example-basic"> <h3>説明文1</h3> <section> <p>説明・・・・・</p> <input type="checkbox" class="required"/> 確認しました </section> <h3>説明文2</h3> <section> <p>説明・・・・・</p> <input type="checkbox" class="required"/> 確認しました </section> <h3>説明文3</h3> <section> <p>説明・・・・・</p> <input type="checkbox" class="required"/> 確認しました </section> <h3>説明文4</h3> <section> <p>説明・・・・・</p> <input type="checkbox" class="required"/> 確認しました </section> </div> <script> $("#example-basic").steps({ headerTag: "h3", bodyTag: "section", transitionEffect: "slideLeft", onFinished: function (event, currentIndex) { window.location.href = "#"; } }); </script>
試したこと
元の記述
<form id="example-form" action="#"> <div> <h3>Account</h3> <section> <label for="userName">User name *</label> <input id="userName" name="userName" type="text" class="required"> <label for="password">Password *</label> <input id="password" name="password" type="text" class="required"> <label for="confirm">Confirm Password *</label> <input id="confirm" name="confirm" type="text" class="required"> <p>(*) Mandatory</p> </section> <h3>Profile</h3> <section> <label for="name">First name *</label> <input id="name" name="name" type="text" class="required"> <label for="surname">Last name *</label> <input id="surname" name="surname" type="text" class="required"> <label for="email">Email *</label> <input id="email" name="email" type="text" class="required email"> <label for="address">Address</label> <input id="address" name="address" type="text"> <p>(*) Mandatory</p> </section> <h3>Hints</h3> <section> <ul> <li>Foo</li> <li>Bar</li> <li>Foobar</li> </ul> </section> <h3>Finish</h3> <section> <input id="acceptTerms" name="acceptTerms" type="checkbox" class="required"> <label for="acceptTerms">I agree with the Terms and Conditions.</label> </section> </div> </form> <script> var form = $("#example-form"); form.validate({ errorPlacement: function errorPlacement(error, element) { element.before(error); }, rules: { confirm: { equalTo: "#password" } } }); form.children("div").steps({ headerTag: "h3", bodyTag: "section", transitionEffect: "slideLeft", onStepChanging: function (event, currentIndex, newIndex) { form.validate().settings.ignore = ":disabled,:hidden"; return form.valid(); }, onFinishing: function (event, currentIndex) { form.validate().settings.ignore = ":disabled"; return form.valid(); }, onFinished: function (event, currentIndex) { alert("Submitted!"); } }); </script>
この元ソースコードをいろいろいじって試してみましたが、
エラー表示どころか画面が固まってしまいます・・・
回答1件
あなたの回答
tips
プレビュー