Hela Halloula GS
Hela Halloula GS

Reputation: 37

Validation input box and textarea

I want validate this tab content with jQuery, I want validate only second div with id='lang2'. How can I do this?

<div class="tab-content ">
<div id="lang1" class="tab-pane  ">
   <div class="col s12">
      <div class="form-group  " id="lang_name">
         <input class="form-control contact-method" placeholder="Enter property name" name="name[1]" type="text">
         <label for="name[1]">Property name</label>                                                                                
      </div>
   </div>
   <div class="col s12">
      <textarea class="hidden desc-content contact-method" name="description[1]" cols="50" rows="10"></textarea>
      <label for="require" class="error-input"> Please enter your description* </label>
   </div>
</div>
<div id="lang2" class="tab-pane active ">
<div class="col s12">
   <div class="form-group  " id="lang_name">
      <input class="form-control contact-method" placeholder="Enter property name" name="name[2]" type="text">
      <label for="name[2]">Property name</label>
      <textarea class="hidden desc-content contact-method" name="description[1]" cols="50" rows="10"></textarea>                                                                     
   </div>
</div>

Upvotes: 1

Views: 637

Answers (1)

Hamza Haider
Hamza Haider

Reputation: 738

This will works for you.

$('#submit').on(click, function () { 


        $('#lang2').find("input[type=text],textarea").each(function (e)
        {

                if ($(this).val().trim() === "")
                {
                   Alert('Please Enter Value')
                   return false;    
                 }
                }

        });

Upvotes: 1

Related Questions