title: Set default value of input field with read-only attribute
body: <p>I have a form that posts persistent data to an SQL database. In my form I have an input field that is at first set to read-only, unless the user selects an option:</p>
  
  <p><a href="https://i.stack.imgur.com/Lf7Lr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lf7Lr.png" alt="enter image description here"></a></p>
  
  <p>My problem is that if the user chooses not to enter a value in the input field, I receive this error:</p>
  
  <p><a href="https://i.imgur.com/cBO4lff.png" rel="nofollow noreferrer"><img src="https://i.imgur.com/cBO4lff.png" alt="enter image description here"></a></p>
  
  <p>I tried setting the default value of the input in my javascript, but i receive the same error.</p>
  
  <pre><code>$("#lejeperiode").val(" ");
  </code></pre>
  
  <p>It doesn't matter whether an empty string or null is inserted into the DB.
  This is my input field:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;input id="periodeInput" class="form-control" type="text" name="lejeperiode" value="@(Request.Form["lejeperiode"] != null ? Request.Form["lejeperiode"].ToString() : "")"/&gt;
  </code></pre>