title: Validate text box - data must be from auto complete (400 values)
body: <p>I am trying to validate my form. I have added a text box with a auto complete. Sometimes people enter random stuff and clicks save.</p>
  
  <p>However i want them to only use the auto complete data. so i was thinking if they enter something random it will give an error.</p>
  
  <p>To do this I am finding difficulties and need some guidance.</p>
  
  <p>This is how my current code looks like:</p>
  
  <p>Textbox:</p>
  
  <pre><code>    &lt;div class="genericFormText" id="test"&gt;Ticket SN:&lt;/div&gt;
                          &lt;div class="genericFormField"&gt;
                              @Html.TextBoxFor(m=&gt;m.Form.Ser_Num) 
  &lt;/div&gt;
  </code></pre>
  
  <p>Autocomplete code:</p>
  
  <pre><code>$("#Form_Ser_Num").autocomplete({
              source: "@Url.Action("SerialProdNumStockSiteAutoComplete", "Ajax")?stocksitenum=LW&amp;model=" + $("#Form_Prod_Num").val(),
  
              minlength: 2,
              delay: 300,
              select: function (event, ui) {
                  event.preventDefault();
                  event.target.innerText = ui.item.label.split(',')[0];
                  $("#Form_Ser_Num_Source").val(ui.item.label.split(',')[1]);
              }
          });
  </code></pre>
  
  <p>Save :</p>
  
  <pre><code>    var data = $("#ticketDetailsForm").serializeArray();
  
              $("#TicketDialog").load("@Url.Action("SaveInstallationTicketDetails", "SOP")", data, function () {
                  //console.log("Saved suucessfully");
                  alert("in save function");
  </code></pre>
  
  <p>backend code:</p>
  
  <pre><code>    public PartialViewResult SaveInstallationTicketDetails(InstallationTicketDetailsForm Form, string JobTypeSelected)
      {
          var viewData = new InstallationTicketDetails(Form.Call_Num);
          Form.Save(User.Identity.Name, JobTypeSelected, viewData.SendCompany, viewData.RelayWeight);
  
          viewData = new InstallationTicketDetails(Form.Call_Num);
          viewData.Form = Form;
          return PartialView("_InstallationTicketDetails", viewData);
      }
  </code></pre>
  
  <p>What is the best way for me to validate the text box to ensure no random data is added and only autocompelte data is selected, any idea or help would be very appreciated.</p>
  
  <p><strong>is there something where i can do a if statement to see if the data is not equal to the auto complete then show an alert?</strong></p>