jQuery Validation Plugin
jQuery Validation Plugin 是一個前端驗證套件,使用範例如下
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> </head> <body> <form action="" id="testForm"> <input name="aaa" type="text" required minlength="2"> <br /> <input id="bbb" type="text" required minlength="4"> <br /> <input name="ccc" type="text" required minlength="8"> <br /> <input type="submit" value="submit"> </form> <script src="https://code.jquery.com/jquery-3.1.0.js"></script> <script src="https://cdn.jsdelivr.net/npm/jquery-validation@1.19.0/dist/jquery.validate.js"></script> <script> $("#testForm").validate(); </script> </body> </html>
測試畫面如下圖
參考資料: