开发者

custom message in validate jQuery plugin

开发者 https://www.devze.com 2023-02-09 07:47 出处:网络
I am using jquery validate plugin (http://bassistance.de/jquery-plugins/jquery-plugin-validation/). the default message to warn user to complete required field is \"This field is 开发者_StackOverflow

I am using jquery validate plugin (http://bassistance.de/jquery-plugins/jquery-plugin-validation/).

the default message to warn user to complete required field is "This field is 开发者_StackOverflow社区required." but i want to change it.

how can i change it? I don't want to define a message for each field,I want a new message for all fields.

I use this code,but message doesn't change:

$("#RegisterForm").validate({
          messages: {
               required: "This field is ."
          }
});


After you run your validate method. Do this $.validator.messages['required'] = 'my message'; Or

alternatively you can pass this as an option in your validate method

.validate({
   //options
   messages: {
     required: "my message"
   }
});


I found these codes and it did what I want:

jQuery.extend(jQuery.validator.messages, 
     { required: "My message" });
0

精彩评论

暂无评论...
验证码 换一张
取 消