Validation for two fields on a form

Multi tool use
Validation for two fields on a form
I was wondering if anyone could please need help me validate my form.
The two fields that need validation are house number and postcode
I need to make the house number only two numbers
and the postcode only 5 characters.
I've used a pattern attribute and was wondering if I can display the message on more than one field.
Address
Plant Type
TREE
SHRUB
Description
Rating
<br>
<br>
<button type="submit">SUBMIT</button>
</form>
Can you describe your requirement in detail?
– The KNVB
Jul 2 at 11:05
“I need to make the house number only two numbers” - to which Sherlock Holmes just replied, Don’t be a moron, Watson - and remember that we live at 221B Baker Street.
– CBroe
Jul 2 at 11:14
I want to be able to display a message for both input fields It only shows one at a time when I use html validation..
– Calvin
Jul 3 at 12:53
2 Answers
2
Simply you can can do it using a html attribute maxlength = "2"
For Example
Address
Plant Type
TREE
SHRUB
Description
Rating
<br>
<br>
<button type="submit">SUBMIT</button>
</form>
simply you can use this code
css :-
input:valid {
color: green;
}
input:invalid {
color: red;
}
Address
Plant Type
TREE
SHRUB
Description
Rating
<br>
<br>
<button type="submit">SUBMIT</button>
</form>
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
try regular expression w3schools.com/jsref/jsref_obj_regexp.asp
– sayalok
Jul 2 at 11:03