diff --git a/Frontend/js/style.js b/Frontend/js/style.js index 4817d3c..aea62e5 100644 --- a/Frontend/js/style.js +++ b/Frontend/js/style.js @@ -133,6 +133,17 @@ YT.Math.Random = function (min, max) { /// function jquValAddMethod() { if ($.validator) { + $.validator.setDefaults({ + onkeyup: function (element, event) { + $(element).valid(); + }, + //errorPlacement: function (error, element) { + // if (element.hasClass("removedTitle")) + // error.insertAfter(element.next("img")); + // else + // error.insertAfter(element); + //} + }); $.validator.addMethod("requiredSelect", function (value, element) { let selVal = $(element).find(`option:selected`).val(); @@ -149,6 +160,14 @@ function jquValAddMethod() { } return true; }, "必須選擇") + $.validator.addMethod("phone", function (phoneNumber, element) { + phoneNumber = phoneNumber.replace(/\s+/g, ""); + return phoneNumber.match(/^[0-9]{9,10}$/); + }, "請輸入正確電話號碼格式"); + + $.validator.addMethod("dbLimit", function (value, element, param) { + return value.length > param; + }, "超出輸入限制"); } }