title: Dynamically adding pattern and title attributes to input control
body: <p>I have a HTML input control as follows:</p>
  
  <pre><code>&lt;input type="text" value="&lt;%= this.CustomerAcctNumber %&gt;" name="CustomerAcctNumber" id="CustomerAcctNumber" maxlength="19" onkeyup="CustomerAcctNumberChange()" required &gt;
  </code></pre>
  
  <p>on body onload I am adding a pattern and title attributes to this input control</p>
  
  <pre><code>var CustomerAcctNumber = document.getElementById("CustomerAcctNumber");
  CustomerAcctNumber.setAttribute("pattern","\d{2}-(?:\d{4}-){3}\d{1}");
  CustomerAcctNumber.setAttribute("title","xx-xxxx-xxxx-xxxx-x");
  </code></pre>
  
  <p>When i submit this web page, with valid pattern, it gives me error : </p>
  
  <p><a href="https://i.stack.imgur.com/b4BpK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b4BpK.png" alt="enter image description here"></a></p>
  
  <p>Input control was rendered as expected as follows : </p>
  
  <pre><code>&lt;input type="text" value="" name="CustomerAcctNumber" id="CustomerAcctNumber" maxlength="19" onkeyup="CustomerAcctNumberChange()" pattern="d{2}-(?:d{4}-){3}d{1}" title="xx-xxxx-xxxx-xxxx-x" required=""&gt;
  </code></pre>
  
  <p>Any suggestions or comments will be appreciated!!</p>