When using JavaScript to set a value on an input with `minlength`, the input is not marked as invalid unless the user interacts with the field.
```
<input id=test minlength=5><script>document.getElementById("test").value = '1234'</script>
```
Contrast this with a `pattern` validation, where the input is immediately marked as invalid.
```
<input id=test minlength=5><script>document.getElementById("test").value = '1234'</script>
```
I thought maybe it was because [minlength is controller by the dirty value flag](https://www.w3.org/TR/html52/sec-forms.html#the-maxlength-and-minlength-attributes) and [pattern isn't](https://www.w3.org/TR/html52/sec-forms.html#the-pattern-attribute), but [it sounds like the dirty value flag should affected by script changes](https://www.w3.org/TR/html52/sec-forms.html#input-dirty-value-flag).
Bug 1526404 Comment 0 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
When using JavaScript to set a value on an input with `minlength`, the input is not marked as invalid unless the user interacts with the field.
```
<input id=test minlength=5><script>document.getElementById("test").value = '1234'</script>
```
Contrast this with a `pattern` validation, where the input is immediately marked as invalid.
```
data:text/html,<input id=test pattern=".{5,}"><script>document.getElementById("test").value = '1234'</script>
```
I thought maybe it was because [minlength is controller by the dirty value flag](https://www.w3.org/TR/html52/sec-forms.html#the-maxlength-and-minlength-attributes) and [pattern isn't](https://www.w3.org/TR/html52/sec-forms.html#the-pattern-attribute), but [it sounds like the dirty value flag should affected by script changes](https://www.w3.org/TR/html52/sec-forms.html#input-dirty-value-flag).
When using JavaScript to set a value on an input with `minlength`, the input is not marked as invalid unless the user interacts with the field.
```
<style>input:invalid { background-color: red;}</style><input id=test minlength=5><script>document.getElementById("test").value = '1234'</script>
```
Contrast this with a `pattern` validation, where the input is immediately marked as invalid.
```
<style>input:invalid { background-color: red;}</style><input id=test pattern=".{5,}"><script>document.getElementById("test").value = '1234'</script>
```
I thought maybe it was because [minlength is controller by the dirty value flag](https://www.w3.org/TR/html52/sec-forms.html#the-maxlength-and-minlength-attributes) and [pattern isn't](https://www.w3.org/TR/html52/sec-forms.html#the-pattern-attribute), but [it sounds like the dirty value flag should affected by script changes](https://www.w3.org/TR/html52/sec-forms.html#input-dirty-value-flag).
When using JavaScript to set a value on an input with `minlength`, the input is not marked as invalid unless the user interacts with the field.
```
<style>input:invalid { background-color: red;}</style>
<input id=test minlength=5>
<script>document.getElementById("test").value = '1234'</script>
```
Contrast this with a `pattern` validation, where the input is immediately marked as invalid.
```
<style>input:invalid { background-color: red;}</style>
<input id=test pattern=".{5,}">
<script>document.getElementById("test").value = '1234'</script>
```
I thought maybe it was because [minlength is controller by the dirty value flag](https://www.w3.org/TR/html52/sec-forms.html#the-maxlength-and-minlength-attributes) and [pattern isn't](https://www.w3.org/TR/html52/sec-forms.html#the-pattern-attribute), but [it sounds like the dirty value flag should affected by script changes](https://www.w3.org/TR/html52/sec-forms.html#input-dirty-value-flag).