jquery-validate

How can I verify that user name starts with a letter and contains only alphanumeric characters?

只愿长相守 提交于 2020-01-03 02:51:13
问题 I am using Jquery Validation. Currently, I have a username, what i want to validate for this username is: Not blank Availability No whitespaces, I add this method: $.validator.addMethod("nowhitespace", function(value, element) { return this.optional(element) || /^\S+$/i.test(value); }, " No white space please"); Alphanumeric $.validator.addMethod("alphanumeric", function(value, element) { return this.optional(element) || /^[a-zA-Z0-9]+$/i.test(value); }, " Alphanumeric. Only numbers and

Disable submit button when form is invalid

◇◆丶佛笑我妖孽 提交于 2020-01-02 18:16:10
问题 I have a form that I validate with jQuery Validate. I want to be able to disable the submit button when the form is invalid but I am unsure of the best approach. To disable the button I can simply do this $("#clientConfigurationForm input[type=submit]") .prop("disabled", !clientConfigValidation.valid()); The issue is where do I put this code? It seems that the only way to track all changes is to replicate the code in both unhighlight and highlight . Is there a better way to approach this

jQuery Validator Minimum Required Words

て烟熏妆下的殇ゞ 提交于 2020-01-02 08:52:27
问题 I'm looking for a way to validate some input textareas using jQuery -- unfortunately as awesome as the jQuery validator plugin is, it lacks the validation (to my knowledge) "minimum required words". I don't have the code with me (I'll edit in the morning), but I wrote a function that counts the words in your input, but that wasn't clean validation like the plugin provides. I also looked into word-and-character-count.js, but that also does not provide a minimum word count in order to submit

Reseting the form when usering the jquery validations plugin

你。 提交于 2020-01-02 05:37:13
问题 I have a simple form like below that I have added the jQuery validations plugin onto (http://docs.jquery.com/Plugins/Validation). I have this form in a modal popup window so if there are errors and the user closes the window when they open it again the form still has the errors. In my popup close callback I tried calling resetForm() but it says the method doesn't exist. Form HTML: <form class="validations" id="commentForm" method="get" action=""> <p> <label for="name">Name</label> <em>*</em>

Custom error messages for Groups within the jQuery Validation plugin

浪尽此生 提交于 2020-01-02 03:12:09
问题 I'm using the jQuery Validation plugin and i've started to group some of my fields together: groups: { fullName: "myFirstName myLastName" }, I've also added the fields to the rules section so that they are validated: rules: { myFirstName: { required: true }, myLastName: { required: true } }, This works great and produces an error of "This field is required" for the group. My question lies with custom error messages. I have the following setup: messages: { fullName: "Please enter both your

How do I disable “eager” validation entirely using jquery validate?

左心房为你撑大大i 提交于 2020-01-02 02:15:18
问题 Is there a way to disable "eager" validation using the jquery.validate plugin? Either through an option in the script or as a hack? "Eager" validation kicks in once the form has been validated once - after that, invalid fields are validated onfocusout. I want to disable this behavior, and change my forms to only be validated when the submit button is pressed. I don't mind hacking through the validate script itself also, so if that's what the solution requires that's acceptable. 回答1: Check out

Knockoutjs template foreach, special first item

天大地大妈咪最大 提交于 2020-01-02 00:55:30
问题 So i have been busting my brain figuring this out. I have a foreach, spitting out templates, and i want the first element to have a special attribute. So far solutions i have found havent worked. This is the foreach: <h3 class="question">Geografi</h3> <p class="answer" data-bind="template: { name: 'geographyTmpl', foreach: geographyList, templateOptions: { selections: selectedGeographies } }"></p> This is the template: <script id="geographyTmpl" type="text/html"> <input class="geoCheckList"

jquery validate minlength rule is not working

戏子无情 提交于 2020-01-01 08:45:05
问题 I have a form with a password field. The password has to be at least 8 characters long. <form action="/account/register" method="post" id="form-register"> <div class="input-row"> <input name="data[User][password]" type="password" id="FUserPassword" class="required" placeholder="Password"> </div> </form> $("#form-register").validate({ rules: { FUserPassword : { minlength: 8 } } }); It applies the "required" rule, but it just ignores the "minlength" rule. What am I doing wrong? I'm using the

jquery validate minlength rule is not working

*爱你&永不变心* 提交于 2020-01-01 08:44:11
问题 I have a form with a password field. The password has to be at least 8 characters long. <form action="/account/register" method="post" id="form-register"> <div class="input-row"> <input name="data[User][password]" type="password" id="FUserPassword" class="required" placeholder="Password"> </div> </form> $("#form-register").validate({ rules: { FUserPassword : { minlength: 8 } } }); It applies the "required" rule, but it just ignores the "minlength" rule. What am I doing wrong? I'm using the

Validating Decimal Numbers

心已入冬 提交于 2020-01-01 08:33:15
问题 I have a form and I am using jQuery validation plugin to validate it. Now I am trying to validate decimal number input. I have tried the following code, but its not working. Is the problem with the regular expression or the way of writing the custom rule is wrong in my code? rules: { paid_amount: { required:true, rexp: ^[1-9]\d*(\.\d+)?$ }, } }, messages: { paid_amount: { required: "Enter Paid Amount", rexp:"Decimal Numbers Only" }, } }); 回答1: You can use the number validation method found