Pattern not working with readonly attributes
up vote
0
down vote
favorite
I have this form where user need to submit the num of days and it cannot be less than 1. So, I put a pattern there and with read only attribute.
My question is, why the pattern is not working when I put the readonly attribute? Let say, the numofdays is zero, supposedly when I submit, it will say the pattern is not match. But, when I put the readonly, the pattern is not working and the form is submitted even if the pattern is not correct. Is there any way that I can do this?
HTML
<form>
<input class="form-control" type="text" name="numofdays" id="id1" value="diffdays" pattern="[1-9]" title="No of days should not be less than 1" readonly>
<input type="submit" value="Submit" class="btn btn-primary">
</form>
html forms
add a comment |
up vote
0
down vote
favorite
I have this form where user need to submit the num of days and it cannot be less than 1. So, I put a pattern there and with read only attribute.
My question is, why the pattern is not working when I put the readonly attribute? Let say, the numofdays is zero, supposedly when I submit, it will say the pattern is not match. But, when I put the readonly, the pattern is not working and the form is submitted even if the pattern is not correct. Is there any way that I can do this?
HTML
<form>
<input class="form-control" type="text" name="numofdays" id="id1" value="diffdays" pattern="[1-9]" title="No of days should not be less than 1" readonly>
<input type="submit" value="Submit" class="btn btn-primary">
</form>
html forms
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have this form where user need to submit the num of days and it cannot be less than 1. So, I put a pattern there and with read only attribute.
My question is, why the pattern is not working when I put the readonly attribute? Let say, the numofdays is zero, supposedly when I submit, it will say the pattern is not match. But, when I put the readonly, the pattern is not working and the form is submitted even if the pattern is not correct. Is there any way that I can do this?
HTML
<form>
<input class="form-control" type="text" name="numofdays" id="id1" value="diffdays" pattern="[1-9]" title="No of days should not be less than 1" readonly>
<input type="submit" value="Submit" class="btn btn-primary">
</form>
html forms
I have this form where user need to submit the num of days and it cannot be less than 1. So, I put a pattern there and with read only attribute.
My question is, why the pattern is not working when I put the readonly attribute? Let say, the numofdays is zero, supposedly when I submit, it will say the pattern is not match. But, when I put the readonly, the pattern is not working and the form is submitted even if the pattern is not correct. Is there any way that I can do this?
HTML
<form>
<input class="form-control" type="text" name="numofdays" id="id1" value="diffdays" pattern="[1-9]" title="No of days should not be less than 1" readonly>
<input type="submit" value="Submit" class="btn btn-primary">
</form>
html forms
html forms
asked Nov 7 at 9:17
fatin amirah
147
147
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
That's by design.
Constraint validation: If the readonly attribute is specified on an
input element, the element is barred from constraint validation.
Source: https://www.w3.org/TR/html5/forms.html#the-readonly-attribute
Ooh..Now I get it. Thank you for the explanation! :))
– fatin amirah
Nov 7 at 9:25
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
That's by design.
Constraint validation: If the readonly attribute is specified on an
input element, the element is barred from constraint validation.
Source: https://www.w3.org/TR/html5/forms.html#the-readonly-attribute
Ooh..Now I get it. Thank you for the explanation! :))
– fatin amirah
Nov 7 at 9:25
add a comment |
up vote
0
down vote
That's by design.
Constraint validation: If the readonly attribute is specified on an
input element, the element is barred from constraint validation.
Source: https://www.w3.org/TR/html5/forms.html#the-readonly-attribute
Ooh..Now I get it. Thank you for the explanation! :))
– fatin amirah
Nov 7 at 9:25
add a comment |
up vote
0
down vote
up vote
0
down vote
That's by design.
Constraint validation: If the readonly attribute is specified on an
input element, the element is barred from constraint validation.
Source: https://www.w3.org/TR/html5/forms.html#the-readonly-attribute
That's by design.
Constraint validation: If the readonly attribute is specified on an
input element, the element is barred from constraint validation.
Source: https://www.w3.org/TR/html5/forms.html#the-readonly-attribute
answered Nov 7 at 9:19
maio290
1,286314
1,286314
Ooh..Now I get it. Thank you for the explanation! :))
– fatin amirah
Nov 7 at 9:25
add a comment |
Ooh..Now I get it. Thank you for the explanation! :))
– fatin amirah
Nov 7 at 9:25
Ooh..Now I get it. Thank you for the explanation! :))
– fatin amirah
Nov 7 at 9:25
Ooh..Now I get it. Thank you for the explanation! :))
– fatin amirah
Nov 7 at 9:25
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53186475%2fpattern-not-working-with-readonly-attributes%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown