title: Validate numbers in textbox using Jquery in MVC(Razor)
body: <p>I have this:</p>
  <pre><code>@Html.TextBoxFor(cModel =&gt; cModel.Value, new { id = &quot;txtbLimit&quot;, @type = &quot;int&quot; })
  </code></pre>
  <p>And I want to make sure that what the user puts in there is an integer.</p>
  <p>How can I do that?</p>
  <p>EDIT: I dont parse this textBox with a value of a Model, so model validation is not what I want</p>
  <p>EDIT2:</p>
  <h3>Model:</h3>
  <pre><code>public class StorageConfigurationModel
  {
      [Required]
      public int QueueMonitorConfigurationsID { get; set; }
      [Required]
      public PathType QueueMonitorConfigTypeName { get; set; }
      [Required]
      public string Location { get; set; }
      [Required]
      public UnitType QueueMonitorValueTypeName { get; set; }
      [Required]
      public ThresholdType Threshold { get; set; }
      [Required]
      [RegularExpression(@&quot;\d*&quot;)]
      public int Value { get; set; }
  }
  
  public enum PathType
  {
      Path
  }
  public enum UnitType
  {
      MB, GB, TB, Files, Percentage
  }
  public enum ThresholdType
  {
      Upper, Lower
  }
  </code></pre>
  <p>Parse function:</p>
  <pre><code>    private static StorageConfigurationModel BindToModel(int id, string pathType, string threshold, string valueType, string location, int limit)
      {
          return new StorageConfigurationModel
          {
              QueueMonitorConfigurationsID = id,
              QueueMonitorConfigTypeName = (PathType)Enum.Parse(typeof(PathType), pathType),
              Location = Convert.ToString(location.Trim()),
              Value = Convert.ToInt32(limit),
              QueueMonitorValueTypeName = (UnitType)Enum.Parse(typeof(UnitType), valueType),
              Threshold = (ThresholdType)Enum.Parse(typeof(ThresholdType), threshold)
          };
      }
  </code></pre>
  <p>So when I put all the data in my view and click add, nothing is triggered.</p>
  <p>With this I call the function that calls the modelbinder:</p>
  <pre><code>        $.post('@Url.Action(&quot;AddUpdateConfigs&quot;)',
              {id: @Model.QueueMonitorConfigurationsID , pathType: $('#ddlConfigTypeName').val(), threshold:$('#ddlThreshold').val(), valueType:$('#ddlValueTypeName').val(), location: $('#txtbLocation').val(), limit: $('#txtbLimit').val(), config: $('#NewOrUpdate').val() },
              function(data){
                  if (!data.Success){
                      alert(data.Description);
                  }
                  else{
                      //$('#gridView').load('/Storage/gvConfigurations');
                      $.get('@Url.Action(&quot;gvConfigurations&quot;, &quot;Storage&quot;)',null,function(data){$('#gridView').html(data);},'html');
                  }
              },'json');
  </code></pre>