0

I have a form:

<form id="actualForm"  action="" novalidate="novalidate">
        <div class="o-group">
            <input placeholder="Title"  id="name" name="title">
        </div>        
        <div class="o-group">
            <textarea id="description">Enter Description </textarea>
        </div> 
        <div class="o-group">
            <input placeholder="Name" id="name" name="name">
        </div>
</form>

In the above form description field is nic Text Editor field, that means value of this field will not be retrieved by id="description" and name is auto Complete field, So when I put validation rules for the above:

> $("#actualForm").validate({
>                rules:{
>                         title: {
>                                 required: true,
>                                 minlength: 2
>                         },
>                         description: {
>                                 required: true,
>                                 minlength: 2
>                         }
>                 },
>                 messages: {
>                         title: {
>                                 required: "Please enter a title",
>                                 minlength: "At least 2 characters"
>                         },
>                         description: {
>                                 required: "Please enter a description",
>                                 minlength: "At least 2 characters"
>                         }
>                 },
>                 submitHandler: function(form) { return false; }
>         });

Now when I call object.validate(); it does not validate description field and how to validate name field?

1 Answer 1

1

**

function validateForm(){
// Create hidden input fields for description and name
// Assign values to them as:
$("hiddenDescription").val($(".nicEdit-main").html());
$("hiddenName").val("take value from autocomplete");
$("#actualForm").validate({
                 ignore:"", 
>                rules:{
>                         title: {
>                                 required: true,
>                                 minlength: 2
>                         },
>                         description: {
>                                 required: true,
>                                 minlength: 2
>                         }
>                 },
>                 messages: {
>                         title: {
>                                 required: "Please enter a title",
>                                 minlength: "At least 2 characters"
>                         },
>                         description: {
>                                 required: "Please enter a description",
>                                 minlength: "At least 2 characters"
>                         }
>                 },
>                 submitHandler: function(form) { return false; }
>         });
}

**

Validation messages will be displayed below hidden fields, place them according to your need.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.