I'm trying to create a form, and set the pattern and title fields programatically through JS. Can someone help me with working out why this isn't working. The code below results in not being able to enter anything into the form field and the popup error saying "match the requested format".
var node = document.getElementById("text");
node.setAttribute("pattern", "\d+");
node.setAttribute("title", "Six or more characters");
<p>A form with a password field that must contain a positive integer:</p>
<form action="/action_page.php">
Enter a number: <input type="text" id="text" name="text">
<input type="submit">
</form>