需要检查表单的一个部分中的文本字段是否已填写

时间:2017-03-13 06:25:41

标签: javascript html

我需要一些帮助。 这是我的表单的链接: http://sujdhuj.com/dawood/

在此表单中,在调查要求部分中,有以下选项:办公室清洁,建筑物清洁,酒店清洁,等。如果我点击办公室清洁 ,将显示 Office清洁表单的要求,其他选项也是如此。

现在,我需要一个代码,要求用户至少填写清洁调查的一部分,可以是办公室清洁,酒店清洁或任何其他部分。如果用户没有填写调查要求中的任何部分,则需要显示警报。如果用户填写至少一个部分,则应提交表单。我只需要文本字段而不是单选按钮。 我希望你明白我的观点!

这是代码(我试图对其进行优化以便可能出现一些错误):

<div class="form_title">
 <h3><strong></strong> SERVERY REQUIRMENTS</h3>
</div>

<h2>Building cleaning</h2>
<div>
 <div class="col-md-12"><h4>Building cleaning</h4></div>    
 <div class="form-group options">
   <strong>Interior</strong>
   <label class="switch-light switch-ios pull-right">
    <input type="checkbox" name="option_6" id="option_6" value="Yes">
    <span>
      <span>No</span>
      <span>Yes</span>
    </span>
    <a></a>
  </label>

  <strong>Exterior</strong>
  <label class="switch-light switch-ios pull-right">
    <input type="checkbox" name="option_7" id="option_7" value="Yes">
    <span>
      <span>No</span>
      <span>Yes</span>
    </span>
    <a></a>
  </label>
</div>
</div>

<label>Measurment </label>
<input type="text" class="form-control"   />
</div> 
</div>
<div class="clear"></div>
<hr>
</div>

<h2>Office Cleaning</h2>
<div>
  <div class="col-md-12"><h4>Office Cleaning</h4></div> 

  <strong>General Cleaning</strong>
  <label class="switch-light switch-ios pull-right">
    <input type="checkbox" name="option_8" id="option_8" value="Yes">
    <span>
      <span>No</span>
      <span>Yes</span>
    </span>
    <a></a>
  </label>
</div>

<strong>Deep Cleaning</strong>
<label class="switch-light switch-ios pull-right">
  <input type="checkbox" name="option_9" id="option_9" value="Yes">
  <span>
    <span>No</span>
    <span>Yes</span>
  </span>
  <a></a>
</label>
</div>

<label>Measurment </label>
<input type="text" class="form-control" id="responsive-tab" id="id2"  />
</div> 

<label>Description </label>
<input type="text" class="form-control" id="responsive-tab" id="id3" />
</div> 
</div>
<div class="clear"></div>
<hr> 

<h2>Resturant & Kitchen Cleaning</h2>
<div>
  <div class="col-md-12"><h4>Resturant & Kitchen Cleaning</h4></div>

  <strong>Interior</strong>
  <label class="switch-light switch-ios pull-right">
    <input type="checkbox" name="option_10" id="option_10" value="Yes">
    <span>
      <span>No</span>
      <span>Yes</span>
    </span>
    <a></a>
  </label>
</div>

<strong>Exterior</strong>
<label class="switch-light switch-ios pull-right">
  <input type="checkbox" name="option_11" id="option_11" value="Yes">
  <span>
    <span>No</span>
    <span>Yes</span>
  </span>
  <a></a>
</label>
</div>

<strong>W/Facade</strong>
<label class="switch-light switch-ios pull-right">
  <input type="checkbox" name="option_12" id="option_12" value="Yes">
  <span>
    <span>No</span>
    <span>Yes</span>
  </span>
  <a></a>
</label>
</div> 


<label>Description </label>
<input type="text" class="form-control" id="responsive-tab" id="id4"  />
</div> 
</div>
<div class="clear"></div>
<hr>
</div>

<h2>Hotal Cleaning</h2>
<div>

 <strong>Flat</strong>
 <label class="switch-light switch-ios pull-right">
  <input type="checkbox" name="option_13" id="option_13" value="Yes">
  <span>
    <span>No</span>
    <span>Yes</span>
  </span>
  <a></a>
</label>
</div>

<strong>Villa</strong>
<label class="switch-light switch-ios pull-right">
  <input type="checkbox" name="option_14" id="option_14" value="Yes">
  <span>
    <span>No</span>
    <span>Yes</span>
  </span>
  <a></a>
</label>
</div>

<strong>W/ balcony</strong>
<label class="switch-light switch-ios pull-right">
  <input type="checkbox" name="option_15" id="option_15" value="Yes">
  <span>
    <span>No</span>
    <span>Yes</span>
  </span>
  <a></a>
</label>
</div> 

<label>No. of Bedroom (s):</label>
<input type="text" class="form-control" id="responsive-tab" id="id5" />
</div>
</div>
<div class="col-md-6 col-sm-6">
 <div class="form-group">
   <label>No. of Floor (s):</label>
   <input type="text" class="form-control" id="responsive-tab"  />
 </div>
</div>
<div class="clear"></div>
<hr> 
</div>

<h2>Warehouse Cleaning</h2>

<div>
 <div class="col-md-12"><h4>Warehouse Cleaning</h4></div>
 <strong>General Cleaning</strong>
 <label class="switch-light switch-ios pull-right">
  <input type="checkbox" name="option_16" id="option_16" value="Yes">
  <span>
    <span>No</span>
    <span>Yes</span>
  </span>
  <a></a>
</label>
</div>

<strong>Deep Cleaning</strong>
<label class="switch-light switch-ios pull-right">
  <input type="checkbox" name="option_17" id="option_17" value="Yes">
  <span>
    <span>No</span>
    <span>Yes</span>
  </span>
  <a></a>
</label>
</div>

<label>Measurment </label>
<input type="text" class="form-control" id="responsive-tab"  />
</div> 
</div>
<div class="col-md-6 col-sm-6">
  <div class="form-group">
   <label>Description </label>
   <input type="text" class="form-control" id="responsive-tab"  />
 </div> 
</div>
<div class="clear"></div>
<hr>
</div>

<h2>Residnetial Cleaning</h2>

<div>
 <div class="col-md-12"><h4>Residnetial Cleaning</h4></div>

 <strong>Flat</strong>
 <label class="switch-light switch-ios pull-right">
  <input type="checkbox" name="option_18" id="option_18" value="Yes">
  <span>
    <span>No</span>
    <span>Yes</span>
  </span>
  <a></a>
</label>
</div>

<strong>Villa</strong>
<label class="switch-light switch-ios pull-right">
  <input type="checkbox" name="option_19" id="option_19" value="Yes">
  <span>
    <span>No</span>
    <span>Yes</span>
  </span>
  <a></a>
</label>
</div>

<label>No. of Bedroom (s): </label>
<input type="text" class="form-control" id="responsive-tab"  />
</div> 

<label>Description </label>
<input type="text" class="form-control" id="responsive-tab"  />
</div> 
</div>
<div class="clear"></div>
<hr>
</div>

<h2>Upholstery Cleaning</h2>
<div>
  <div class="col-md-12"><h4>Upholstery Cleaning</h4></div>

  <strong>Sofa</strong>
  <label class="switch-light switch-ios pull-right">
    <input type="checkbox" name="option_20" id="option_20" value="Yes">
    <span>
      <span>No</span>
      <span>Yes</span>
    </span>
    <a></a>
  </label>
</div>
</div>    
<div class="col-md-6 col-sm-6">
  <div class="form-group">
   <label>No. of Seater: </label>
   <input type="text" class="form-control" id="responsive-tab"  />
 </div> 
</div> 

<strong>Carpet</strong>
<label class="switch-light switch-ios pull-right">
  <input type="checkbox" name="option_21" id="option_21" value="Yes">
  <span>
    <span>No</span>
    <span>Yes</span>
  </span>
  <a></a>
</label>
</div>
</div>

<label>Febric:</label>
<input type="text" class="form-control" id="responsive-tab"  />
</div> 
</div>
<label>Measurment: </label>
<input type="text" class="form-control" id="responsive-tab"  />
</div> 
</div>
<div class="clear"></div>
<hr>
</div>

<h2>Glass Cleaning</h2>
<div>
  <div class="col-md-12"><h4>Glass Cleaning</h4></div>

  <strong>Flat</strong>
  <label class="switch-light switch-ios pull-right">
    <input type="checkbox" name="option_22" id="option_22" value="Yes">
    <span>
      <span>No</span>
      <span>Yes</span>
    </span>
    <a></a>
  </label>
</div>
<strong>Villa</strong>
<label class="switch-light switch-ios pull-right">
  <input type="checkbox" name="option_23" id="option_23" value="Yes">
  <span>
    <span>No</span>
    <span>Yes</span>
  </span>
  <a></a>
</label>
</div>

<strong>Interior</strong>
<label class="switch-light switch-ios pull-right">
  <input type="checkbox" name="option_24" id="option_24" value="Yes">
  <span>
    <span>No</span>
    <span>Yes</span>
  </span>
  <a></a>
</label>
</div> 

<strong>Exterior</strong>
<label class="switch-light switch-ios pull-right">
  <input type="checkbox" name="option_25" id="option_25" value="Yes">
  <span>
    <span>No</span>
    <span>Yes</span>
  </span>
  <a></a>
</label>
</div> 

<label>BIo. of Glass: </label>
<input type="text" class="form-control" id="responsive-tab"  />
</div> 
</div>
<div class="clear"></div>
<hr>
</div>
<h2>Water Tank Cleaning</h2>
<div>
 <div class="col-md-12"><h4>Water Tank Cleaning</h4></div>

 <label>No. of Tank: </label>
 <input type="text" class="form-control" id="responsive-tab"  />
</div> 

<label>Type of Tank: </label>
<input type="text" class="form-control" id="responsive-tab"  />
</div> 

<label>Description:  </label>
<input type="text" class="form-control" id="responsive-tab"  />
</div> 
</div>
<div class="clear"></div>
<hr>
</div>
<h2>Move in & Move Out Cleaning</h2>
<div>
 <div class="col-md-12"><h4>Move in & Move Out Cleaning</h4></div>

 <strong>Flat</strong>
 <label class="switch-light switch-ios pull-right">
  <input type="checkbox" name="option_25" id="option_25" value="Yes">
  <span>
    <span>No</span>
    <span>Yes</span>
  </span>
  <a></a>
</label>
</div>
<strong>Villa</strong>
<label class="switch-light switch-ios pull-right">
  <input type="checkbox" name="option_26" id="option_26" value="Yes">
  <span>
    <span>No</span>
    <span>Yes</span>
  </span>
  <a></a>
</label>
</div>

<label>No. of Bedroom (s):  </label>
<input type="text" class="form-control" id="responsive-tab"  />
</div> 
</div>
<div class="col-md-6 col-sm-6">
  <div class="form-group">
   <label>Description:  </label>
   <input type="text" class="form-control" id="responsive-tab"  />
 </div> 
</div>
<div class="clear"></div>
<hr>
</div>
<h2>AC Cleaning</h2>
<div>
 <div class="col-md-12"><h4>AC Cleaning</h4></div>

 <strong>General Cleaning  </strong>
 <label class="switch-light switch-ios pull-right">
  <input type="checkbox" name="option_27" id="option_27" value="Yes">
  <span>
    <span>No</span>
    <span>Yes</span>
  </span>
  <a></a>
</label>
</div>

<strong>Deep Cleaning</strong>
<label class="switch-light switch-ios pull-right">
  <input type="checkbox" name="option_28" id="option_28" value="Yes">
  <span>
    <span>No</span>
    <span>Yes</span>
  </span>
  <a></a>
</label>
</div>

<label>No. of AC(s):  </label>
<input type="text" class="form-control" id="responsive-tab"  />
</div> 
</div>
<div class="col-md-6 col-sm-6">
  <div class="form-group">
   <label>Type of AC (s): </label>
   <input type="text" class="form-control" id="responsive-tab"  />
 </div> 
</div>
<div class="clear"></div>
<hr>
</div>
</div>
<hr>
</div>

1 个答案:

答案 0 :(得分:0)

为什么你不能像这样验证

if(BuldingCleaning.Selected) 
{
// Validate the textbox
}
if(OfficeCleaning.Selected) 
{
//Validate the  text boxes
}

等等