-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Client side validation form - Using JS Only
- Loading branch information
1 parent
891de02
commit f908af3
Showing
6 changed files
with
108 additions
and
86 deletions.
There are no files selected for viewing
65 changes: 0 additions & 65 deletions
65
...cript/intermediate-js/client-side-form-validation-w-js/browser-form-validation/index.html
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
...script/intermediate-js/client-side-form-validation-w-js/browser-form-validation/style.css
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...on-w-js/browser-form-validation/README.md → ...s/form-validation-using-only-js/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...intermediate-js/client-side-form-validation-w-js/form-validation-using-only-js/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Browser Form Validation</title> | ||
<script src="form-validation.js" defer></script> | ||
<link rel="stylesheet" href="./style.css" /> | ||
</head> | ||
<body> | ||
<div class="whole"> | ||
<h3>Sample form w password field <br>(Yes, regex validation included)</h3> | ||
<div class="container"> | ||
<form novalidate id="form"> | ||
<div> | ||
<label for="email">Email: </label> | ||
<input type="email" id="email" /> | ||
<span class="error"></span> | ||
</div> | ||
<div> | ||
<label for="select-country">Country:</label> | ||
<select name="country" id="select-country" > | ||
<option value="">--Please choose an option--</option> | ||
<option value="IND">India</option> | ||
<option value="USA">United States</option> | ||
<option value="VIE">Vietnam</option> | ||
<option value="GER">Germany</option> | ||
<option value="THA">Thailand</option> | ||
<option value="UAE">United Arab Emirates</option> | ||
</select> | ||
<span class="error"></span> | ||
</div> | ||
<div> | ||
<label for="zipcode">Zip Code:</label> | ||
<input | ||
type="text" | ||
inputmode="numeric" | ||
pattern="\d*" | ||
id="zipcode" | ||
minlength="5" | ||
maxlength="5" | ||
|
||
/> | ||
<span class="error"></span> | ||
</div> | ||
<div> | ||
<label for="pass">Password: </label> | ||
<input | ||
type="password" | ||
id="pass" | ||
pattern="^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[!@#$%^&*])[A-Za-z\d!@#$%^&*]{5,}$" | ||
minlength="5" | ||
|
||
/> | ||
<span class="error"></span> | ||
</div> | ||
<div> | ||
<button type="submit" id="btn-submit">Submit</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</html> |
37 changes: 37 additions & 0 deletions
37
.../intermediate-js/client-side-form-validation-w-js/form-validation-using-only-js/style.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
html { | ||
width: 100%; | ||
} | ||
|
||
.whole { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.container { | ||
display: flex; | ||
max-width: min-content; | ||
justify-content: end; | ||
} | ||
|
||
.container div { | ||
margin: 20px; | ||
} | ||
|
||
.error { | ||
border-color: red; | ||
padding: 0.2em; | ||
border-radius: 0 0 5px 5px; | ||
} | ||
|
||
input:invalid, | ||
select:invalid { | ||
border-color: #900; | ||
background-color: #ffd; | ||
} | ||
|
||
input:focus:invalid, | ||
select:focus:invalid { | ||
outline: none; | ||
} |