Sean
Sean

Reputation: 2577

Jquery in-line messages and validation

Is it possible to add a custom message per element within a form, but do it inline? For example:

<input type="text" name="mybox" id="mybox" class="required" requiredmessage="This is my custom message." />

I know you can use:

$('#myForm').validate();

to set custom messages, but wondering if I am able to do it inline like I can for the rules?

Upvotes: 1

Views: 1427

Answers (2)

Santosh Sawant
Santosh Sawant

Reputation: 275

You can do the following:

<input type="text" name="mybox" id="mybox" class="required" data-msg-required="This is my custom message." />

Upvotes: 0

Michael
Michael

Reputation: 311

All you need to do is to set the custom message as the title attribute. So for example you could do the following:

<input type="text" class="required" title="This is my custom message." />

I hope that helps.

Michael

Upvotes: 1

Related Questions