PHP Form Validation To Add Class
See my StackOverflow post at https://stackoverflow.com/questions/62107649/add-a-class-to-an-input-using-php
HTML
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1.0">
<title>Apply</title>
<link rel="icon" href="../../Images/Used/Favicon.png" />
<link rel="stylesheet" type="text/css" href="Apply.css" />
<link rel="stylesheet" href="../../Other/Font Awesome/fontawesome-free-5.13.0-web/css/all.css" type="text/css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<nav id="navbar">
<a class="apply activeNav" href="../Apply/Apply.html" title="Apply">Apply</a>
<a class="home" href="../../index.html" title="Home">Home</a>
<a class="logoText" href="../../index.html" title="CompRepair Logo" alt="CompRepair Logo">
<img class="logoPic" src="../../Images/Used/CompRepairLogo.png" />
</a>
<a class="signInText" href="../Account/Sign In/SignIn.html" title="Sign In">
<img class="signInPic" src="../../Images/Used/SignIn.png">
</a>
<div class="dropdown">
<button class="dropbtn" title="Legalities">Legalities
<i class="fa fa-caret-down"></i>
</button>
<div id="myDropdown" class="dropdown-content">
<a href="#">Terms of Service</a>
<a href="#">Privacy Policy</a>
</div>
</div>
<a class="contact" href="../Contact/Contact.html" title="Contact">Contact</a>
</nav>
<div id="banner">
<h2 id="bannerText">Apply For A Job At CompRepair</h2>
</div>
<div id="formIntroParent">
<p class="formIntro">Your application is sent through secure connections.</p>
<p class="formIntro">Have questions about applying? <a href="../Contact/Contact.html" target="_blank">Contact
us!</a></p>
</div>
<form class="applyForm" name="applyForm" action="Apply.php" id="applyForm" method="POST">
<fieldset class="formSection">
<h4>Personal Information</h4>
...
CSS
* {
box-sizing: border-box;
outline: none;
}
html,
body {
width: 100%;
height: 100%;
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: "Segoe UI", Calibri, "Helvetica Neue", Helvetica, Arial, sans-serif;
background: #f6f6f6;
text-align: center;
}
#navbar {
width: 100%;
height: 50px;
background-color: #f1f1f1;
padding-bottom: 5px;
}
#navbar a {
height: 50px;
float: left;
display: block;
color: black;
text-align: center;
padding: 15px 15px;
margin-right: 0.5%;
text-decoration: none;
font-weight: lighter;
font-size: 17px;
transition: color 0.4s ease-in-out;
}
#navbar a:hover {
cursor: pointer;
color: gray;
transition: color 0.4s ease-in-out;
}
#navbar button {
height: 50px;
float: left;
display: block;
color: black;
text-align: center;
padding: 10px 15px;
text-decoration: none;
}
#navbar .openbtnSmall {
display: none;
}
#navbar button:hover {
cursor: pointer;
color: gray;
}
#navbar button:focus {
outline: 0;
}
#navbar a.signInText {
float: right;
opacity: 0.5;
transition: opacity 0.4s ease;
}
#navbar a.signInText:hover {
border: none;
opacity: 1;
transition: opacity 0.4s ease;
}
#navbar a img.signInPic {
max-height: 30px;
margin-top: -3px;
text-align: center;
}
#navbar a.logoText {
float: none;
display: block;
position: absolute;
left: calc(50% - 80px);
opacity: 0.5;
transition: opacity 0.4s ease;
}
#navbar a.logoText:hover {
border-bottom: none;
opacity: 1;
transition: opacity 0.4s ease;
}
#navbar a img.logoPic {
max-height: 30px;
margin-top: -3px;
text-align: center;
position: absolute;
}
#navbar a.activeNav {
font-weight: bold;
}
.dropdown {
float: right;
overflow: hidden;
}
.dropdown .fa-caret-up {
display: none;
}
.dropdown .dropbtn {
font-size: 16px;
border: none;
outline: none;
color: black;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
margin: 0;
...
JavaScript
let form = document.getElementById("applyForm");
function handleForm(event) { event.preventDefault(); }
form.addEventListener('submit', handleForm);
// On click of the text, show/hide the phone number requirements
function showPhoneEx() {
let phNumRequire = document.getElementById('phNumRequire');
let phNumReveal = document.getElementById('phNumReveal');
if (phNumRequire.style.display && phNumRequire.style.display !== 'none') {
// If the requirements are already shown, hide them on click
phNumRequire.style.display = 'none';
phNumReveal.innerHTML = "See how your phone number should be formatted";
} else {
// If the requirements are already hidden, show them on click
phNumRequire.style.display = 'block';
phNumReveal.innerHTML = "Hide how your phone number should be formatted";
}
}
// On change of selection for the employment situation <select> element, show/hide the following element (automatically hidden)
function checkEmployment() {
if (document.getElementById("other").selected) {
// If "Other" is chosen, show the following element
document.getElementById('clarifySituation').style.display = "block";
} else {
// If "Other" is not chosen, hide the following element
document.getElementById('clarifySituation').style.display = "none";
}
}
function resumeCheck() {
if (document.getElementById("yes").selected) {
document.getElementById("resumeOuter").style.display = "block";
} else {
document.getElementById("resumeOuter").style.display = "none";
document.getElementById("fileInput").style.display = "none";
document.getElementById("URLInput").style.display = "none";
}
}
function resumeType() {
if (document.getElementById("url").selected) {
document.getElementById("URLInput").style.display = "block";
document.getElementById("fileInput").style.display = "none";
} else if...