Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, l want to change this code for work on multipul field from same type phone In this code, there is only one field for

Hi, l want to change this code for work on multipul field from same type phone
In this code, there is only one field for the type of phone, and I need more than that, and I found it difficult to modify it. thank you..
css code//
@import url('https://fonts.googleapis.com/css?family=Montserrat:600i&display=swap');
body {
font-family: 'Montserrat', sans-serif;
color: #333;
background: #eee;
}
form {
background: white;
}
label {
margin-bottom: .5rem;
text-align: right;
display: block;
letter-spacing: 2px;
color: #adb5bd;
text-transform: uppercase;
}
.form-control {
border: none;
background: none;
border-bottom: 2px solid rgba(0, 0, 0, 0.2);
transition: border-color .4s ease-out;
border-radius: 0;
}
.form-control:active,
.form-control:focus,
.btn.focus,
.btn:focus {
outline: none;
box-shadow: none;
border-color: black;
}
.form-control.valid {
border-color: green;
}
.form-control.invalid {
border-color: red;
}
.form-control + small {
color: red;
opacity: 0;
height: 0;
transition: opacity .4s ease-out;
}
.form-control.invalid + small {
opacity: 1;
height: auto;
margin-bottom: 20px;
transition: opacity .4s ease-out;
}
.btn {
border: 2px solid black;
padding: 0.375rem 2.75rem;
text-transform: uppercase;
font-weight: 900;
border-radius: 0;
}
.btn:hover {
color: white;
background: black;
transition: all .4s ease-out;
}
////////////////////////
html code ///
Username must be between 5 - 12 characters.
Password must be alphanumeric, 8 - 20 characters (@, _ and - are allowed).
Enter valid email address.
Phone number must be in format 05
///////////////////////////////
javascript code:
const inputs = document.querySelectorAll('input');
const patterns = {
username: /^[a-z\d]{5,12}$/i,
password: /^[\d\w@-]{8,20}$/i,
email: /^([a-z\d\.-]+)@([a-z\d-]+)\.([a-z]{2,8})(\.[a-z]{2,8})?$/,
phone: /^(009665|9665|\+9665|05|5)(5|0|3|6|4|9|1|8|7)([0-9]{7})$/
};
inputs.forEach((input) => {
input.addEventListener('keyup', (e) => {
validate(e.target, patterns[e.target.attributes.id.value]);
});
});
function validate(field, regex) {
if (regex.test(field.value)) {
field.className = 'form-control valid';
} else {
field.className = 'form-control invalid';
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Iv Special Issue On Database Systems For Biomedical Applications Lncs 6990

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Christian Bohm ,Johann Eder ,Claudia Plant

2011th Edition

3642237398, 978-3642237393

More Books

Students also viewed these Databases questions

Question

Understand the different approaches to job design. page 167

Answered: 1 week ago