title: Javascript int variable from ASP.NET MVC Model data?
body: <p>I need to get model data into a javascript variable and use it as an int to compare values. But I can only figure out how to get the model data as strings, otherwise the compiler complains.</p>
  
  <p>So how can I get the max and taskBudgetHours as int variables in the Javascript?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          $("#taskForm").submit(function (e) {
              var taskBudgetHours = $('#BudgetHours').val();
              var max = '&lt;%: Model.Project.RemainingBudgetHours %&gt;';
  
              alert(taskBudgetHours);
              alert(max);
  
              if (taskBudgetHours &lt;= max) { //This doesn't work, seems to treat it as strings...
                  return true;
              }
              else {
                  //Prevent the submit event and remain on the screen
                  alert('There are only ' + max + ' hours left of the project hours.');
                  return false;
              }
          });
      });
  &lt;/script&gt;
  </code></pre>