title: condition check for null field on radio button selection
body: <p><a href="https://i.stack.imgur.com/pnO4W.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pnO4W.jpg" alt="enter image description here"></a>I have a sign up page where i have <strong>two radio buttons</strong> I am <strong>a company</strong> or I am <strong>an individual.</strong> If i selects a company then two fields will appear on the screen company name &amp; registration number and if i select <strong>an individual</strong> then three fields will appear on the screen <strong>Identification document</strong>, <strong>Identification number</strong> and annual income </p>
  
  <p>I am facing a validation issue as after selecting <strong>an individual</strong> if i left identification field blank it doesn't give me proper error.</p>
  
  <blockquote>
    <p>Below is my code</p>
  </blockquote>
  
  <pre><code>&lt;script&gt;
   $(document).ready(function() {
  
              var maxDate = new Date().getDate() - 6570;
              $('#dob').datepicker({autoclose: true, todayHighlight: true,format: 'dd/mm/yyyy',endDate: new Date(new Date().setDate(maxDate))});
              $('#dob1').datepicker({autoclose: true, todayHighlight: true,format: 'dd/mm/yyyy',endDate: new Date(new Date().setDate(maxDate))});
  
              $('#industry').select2();
              $('#industry1').select2();
              $('#country').select2();
              $('#annual_income').select2();
              $('#identification_document').select2();
              $('#designation1').select2();
              $('#practices').select2();
              $('#countryCode').select2();
              $('#counCode').select2();
              $('#sign_up').click(function () {
                  fname = $("#fname").val();
                  lname = $("#lname").val();
                  if($('#country').select2('data') != null){
                      country = $('#country').select2('data').text;
                  }else {
                      country = "";
                  }
  
                  if($('#countryCode').select2('data') != null){
                      code1 = $('#countryCode').select2('data').text;
                  }else {
                      code1 = "";
                  }
                  contact1 = $('#contactNo1').val();
                  email = $("#email").val();
                  client_iam = $('input[name=inlineRadioOptions]:checked').val();
                  company = $('#client_company').val();
                  companyreg = $('#client_company_reg').val();
                  identification_number = $('#identification_num').val();
                  if($('#identific ation_document').select2('data') != null){
                      identification_document = $('#identification_document').select2('data').text;
                  }else {
                      identification_document = "";
                  }
                  if($('#annual_income').select2('data') != null){
                      annual_income = $('#annual_income').select2('data').text;
                  }else {
                      annual_income = "";
                  }
                  password = $("#password").val();
                  cnf_password = $("#cnf_password").val();
                  role = "client";
                  var email_Format = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
                  if(!(email_Format).test(email)){
                      show_notification('error', 'Please enter email in abc@xyz.com format only!');
                      return false;
                  }
                  if (fname == "" || lname == "" || country == "" || code1 == "" || contact1 =="" || email == "" || password == "") {
                      show_notification("error", "Please enter all required fields");
                  }else if(($('input[name="inlineRadioOptions"]:checked').length == 0)) {
                          show_notification('error', 'Please select as you want to signup as a company or an individual.');
                  }else if(company == "" || companyreg == ""){
                      show_notification('error', "please enter company and registration number!!!"); //here is issue i am facing when i left identification_number blank it gives me company field error.
                  }else if(identification_number == ''){
                      show_notification('error', "enter identification number");
                  }else{
                      if (password != cnf_password) {
                          show_notification("error", "Password and confirm password doesn't match");
                      } else {
                          if(!$('#client_terms_checkbox').is(':checked')){
                              show_notification("error","Please accept terms &amp; conditions");
                          }else {
                              $.ajax({
                                  url: "reg",
                                  type: "POST",
                                  headers: {
                                      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                                  },
                                  data: {
                                      fname: fname,
                                      lname: lname,
                                      country: country,
                                      role: role,
                                      company : company,
                                      code: code1,
                                      contact: contact1,
                                      client_iam: client_iam,
                                      companyreg:companyreg,
                                      identification_document: identification_document,
                                      identification_number: identification_number,
                                      annual_income: annual_income,
                                      email: email,
                                      password: password,
                                      postlogin: localStorage.postlogin
                                  },
                                  success: function (data) {
                                      localStorage.removeItem("postlogin");
                                      show_notification("success", "Registered Successfully");
                                      setTimeout(function (result) {
                                          window.location.href = data;
                                      }, 1000);
                                  },
                                  error: function (data) {
                                      show_notification("error", data.responseJSON.message);
                                  }
                              });
                          }
                      }
                  }
  
              });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>Any help would be appreciated...</p>
  
  <blockquote>
    <p>HTML code:</p>
  </blockquote>
  
  <pre><code> &lt;div class="card-body tab-content"&gt;
                          &lt;div class="tab-pane active" id="first1"&gt;
                              &lt;div class="form"&gt;
                                  &lt;div class="row"&gt;
                                      &lt;div class="col-md-6"&gt;
                                          &lt;div class="form-group"&gt;
                                              &lt;input type="text" style="border: 1px solid #ddd; padding: 5px;width: 100%;margin-top: 10px;" class="form-control" name="first_name" id="fname" &gt;
                                              &lt;label style="font-size: 15px;" &gt;First Name*&lt;/label&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                      &lt;div class="col-md-6"&gt;
                                          &lt;div class="form-group"&gt;
                                              &lt;input type="text" style="border: 1px solid #ddd; padding: 5px; width: 100%;   margin-top: 10px;" class="form-control" id="lname" name="lname"&gt;
                                              &lt;label style="font-size: 15px;" &gt;Last Name*&lt;/label&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
  
                                  &lt;div class="row"&gt;
                                      &lt;div class="col-md-6"&gt;
                                          &lt;div class="form-group"  style="margin-bottom: 20px;"&gt;
                                              &lt;select style="margin-top: 25px;" id="country" class="form-control " name="country"&gt;
                                                  &lt;option value=""&gt;&lt;/option&gt;
                                                  &lt;option value=""&gt; Brunei&lt;/option&gt;
                                                  &lt;option value=""&gt; Cambodia&lt;/option&gt;
                                                  &lt;option value=""&gt; Indonesia&lt;/option&gt;
                                                  &lt;option value=""&gt; Laos&lt;/option&gt;
                                                  &lt;option value=""&gt; Malaysia&lt;/option&gt;
                                                  &lt;option value=""&gt; Myanmar&lt;/option&gt;
                                                  &lt;option value=""&gt; Philippines&lt;/option&gt;
                                                  &lt;option value=""&gt; Singapore&lt;/option&gt;
                                                  &lt;option value=""&gt; Thailand&lt;/option&gt;
                                                  &lt;option value=""&gt; Vietnam&lt;/option&gt;
                                              &lt;/select&gt;
                                              &lt;label style="font-size: 15px;" for=""&gt;Select Country*&lt;/label&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
  
                                      &lt;div class="col-md-2"&gt;
                                          &lt;div class="form-group" style="margin-bottom: 20px;"&gt;
                                              &lt;select style="margin-top: 25px;" id="countryCode" class="form-control select2-list" name="phone"&gt;
                                                  &lt;option value=""&gt;&lt;/option&gt;
                                                  &lt;option value=""&gt; +673&lt;/option&gt;
                                                  &lt;option value=""&gt; +855&lt;/option&gt;
                                                  &lt;option value=""&gt; +62&lt;/option&gt;
                                                  &lt;option value=""&gt; +856&lt;/option&gt;
                                                  &lt;option value=""&gt; +60&lt;/option&gt;
                                                  &lt;option value=""&gt; +95&lt;/option&gt;
                                                  &lt;option value=""&gt; +63&lt;/option&gt;
                                                  &lt;option value=""&gt; +65&lt;/option&gt;
                                                  &lt;option value=""&gt; +66&lt;/option&gt;
                                                  &lt;option value=""&gt; +84&lt;/option&gt;
                                              &lt;/select&gt;
                                              &lt;label style="font-size: 15px;" for=""&gt;Country code&lt;/label&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                      &lt;div class="col-md-4"&gt;
                                          &lt;div class="form-group" style="margin-bottom: 20px;"&gt;
                                              &lt;label style="font-size: 15px;" for=""&gt;Contact Number*&lt;/label&gt;
                                              &lt;input type="number" style="border: 1px solid #ddd; padding: 5px;width: 100%;margin-top: 13px;" class="form-control" name="phone1" id="contactNo1" &gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
  
                                  &lt;div class="row"&gt;
                                      &lt;div class="col-md-12" style="padding-left: 0;"&gt;
                                          &lt;div class="form-group"&gt;
                                              &lt;div class="col-md-1" style="padding-left: 0px;padding-right: 0;text-align: center;"&gt; I am&lt;/div&gt;
                                              &lt;div class="col-md-11" style="padding-left: 0px;"&gt;
                                                  &lt;label class="radio-inline radio-styled" style="margin-right: 20px;" &gt;
                                                      &lt;input style="" type="radio" name="inlineRadioOptions" id="company_redio" value="company"&gt;&lt;label for=""&gt;a company&lt;/label&gt;
                                                  &lt;/label&gt;
                                                  &lt;label class="radio-inline radio-styled"&gt;
                                                      &lt;input type="radio" name="inlineRadioOptions" id="individual_redio" value="an individual"&gt;&lt;label for=""&gt;an individual&lt;/label&gt;
                                                  &lt;/label&gt;
                                              &lt;/div&gt;&lt;!--end .col --&gt;
                                          &lt;/div&gt;&lt;!--end .form-group --&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                                  {{--Start company--}}
                                  &lt;div class="row" id="company_div" style="display: none;padding-top: 10px;"&gt;
                                      &lt;div class="col-md-6"&gt;
                                          &lt;div class="form-group"&gt;
                                              &lt;input type="text" style="border: 1px solid #ddd; padding: 5px; width: 100%;   margin-top: 10px;" class="form-control" id="client_company" name="client_company_name"&gt;
                                              &lt;label style="font-size: 15px;" for="client_company"&gt;Company Name*&lt;/label&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                      &lt;div class="col-md-6"&gt;
                                          &lt;div class="form-group"&gt;
                                              &lt;input type="text" style="border: 1px solid #ddd; padding: 5px; width: 100%;   margin-top: 10px;" class="form-control" id="client_company_reg" name="client_company_reg"&gt;
                                              &lt;label style="font-size: 15px;" for="client_company_reg"&gt;Registration Number*&lt;/label&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                                  {{--End Company--}}
  
                                  {{--Start individual--}}
                                  &lt;div class="row" id="individual_div" style="display: none;padding-top: 10px;"&gt;
                                      &lt;div class="col-md-6"&gt;
                                          &lt;div class="form-group"&gt;
                                              &lt;select style="margin-top: 25px;" id="identification_document" class="form-control " name="identification_document"&gt;
                                                  &lt;option value=""&gt; NRIC&lt;/option&gt;
                                                  &lt;option value=""&gt; FIN&lt;/option&gt;
                                                  &lt;option value=""&gt; Passport&lt;/option&gt;
                                              &lt;/select&gt;
                                              &lt;label style="font-size: 15px;" for="identification_document"&gt;Identification Document*&lt;/label&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                      &lt;div class="col-md-6"&gt;
                                          &lt;div class="form-group"&gt;
                                              &lt;input type="text" style="border: 1px solid #ddd; padding: 5px; width: 100%;   margin-top: 10px;" class="form-control" id="identification_num" name="identification_number"&gt;
                                              &lt;label style="font-size: 15px;" for="identification_number"&gt;Identification Number*&lt;/label&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                                  &lt;div class="row" id="individual_annual_div"  style="display: none;padding-top: 5px;"&gt;
                                      &lt;div class="col-md-6"&gt;
                                          &lt;div class="form-group"&gt;
                                              &lt;select style="margin-top: 25px;" id="annual_income" class="form-control " name="annual_income"&gt;
                                                  &lt;option value=""&gt; &lt;10,000 SGD&lt;/option&gt;
                                                  &lt;option value=""&gt; 10,000 - 30,000 SGD&lt;/option&gt;
                                                  &lt;option value=""&gt; &gt;30,000 SGD&lt;/option&gt;
                                              &lt;/select&gt;
                                              &lt;label style="font-size: 15px;" for="annual_income"&gt;Annual income&lt;/label&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                                  {{--End individual--}}
                                  &lt;div class="row" style="padding-top: 20px"&gt;
                                      &lt;div class="col-md-12"&gt;
                                          &lt;div class="form-group"&gt;
                                              &lt;input type="email" style="border: 1px solid #ddd; padding: 5px; width: 100%;   margin-top: 10px;" class="form-control" id="email" name="email"&gt;
                                              &lt;label style="font-size: 15px;" for="email"&gt;Email*&lt;/label&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
  
                                  &lt;div class="row"&gt;
                                      &lt;div class="col-md-6"&gt;
                                          &lt;div class="form-group"&gt;
                                              &lt;input type="password" style="border: 1px solid #ddd; padding: 5px; width: 100%;   margin-top: 10px;" class="form-control" id="password" name="password"&gt;
                                              &lt;label style="font-size: 15px;" for="Password"&gt;Password*&lt;/label&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                      &lt;div class="col-md-6"&gt;
                                          &lt;div class="form-group"&gt;
                                              &lt;input type="password" style="border: 1px solid #ddd; padding: 5px; width: 100%;   margin-top: 10px;" class="form-control" id="cnf_password" name="cnf_password"&gt;
                                              &lt;label style="font-size: 15px;" for="cnf_password"&gt;Confirm Password*&lt;/label&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
  
                                  &lt;div class="row" style="padding-left: 18px"&gt;
                                      &lt;div class="checkbox checkbox-styled tile-text"&gt;
                                          &lt;label&gt;
                                              &lt;input type="checkbox" id="client_terms_checkbox"&gt;
                                              &lt;span&gt; I agree with Quesmi’s &lt;u&gt;&lt;a href="termsofuse"&gt;Terms of Use&lt;/a&gt;&lt;/u&gt; and &lt;u&gt;&lt;a href="privacypolicy"&gt;Privacy Policy&lt;/a&gt;&lt;/u&gt;.&lt;/span&gt;
                                          &lt;/label&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                                  &lt;div class="row"&gt;
                                      &lt;div class="col-md-12" style="text-align: center;"&gt;
                                          &lt;button type="submit" class="btn btn-primary" style="width: 100%;margin-top: 20px;border-color: #FF0000;background-color: #FF0000;" id="sign_up"&gt;Sign Up &lt;/button&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;&lt;!--end .card-body --&gt;
                          &lt;/div&gt;
  </code></pre>