JSFiddle - React, Tailwind, and code Playground
HTML
<form name="form" action="index.html" onsubmit="return construct();" method="post">
<label>Your Name:<span class="req">*</span>
</label>
<input type="text" name="name" />
<br />
<label>Company Name:<span class="req">*</span>
</label>
<input type="text" name="companyName" />
<br />
<label>Phone Number:</label>
<input type="text" name="phone" />
<br />
<label>Email Address:<span class="req">*</span>
</label>
<input type="text" name="email" />
<br />
<label>Best Time to be Contacted:</label>
<input type="text" name="TimeForContact" />
<br />
<label>Availability for Presenting:</label>
<input type="text" name="aval" />
<br />
<label>Message:</label>
<textarea name="message" ROWS="3" COLS="30"></textarea>
<label>First Time Presenting for AGC?:<span class="req">*</span>
</label>
<input type="radio" name="firstTime" value="Yes" id="yes" /><span class="small">Yes</span>
<input type="radio" name="firstTime" value="No" id="no" /><span class="small">No</span>
<br />
<br />
<input type="submit" name="submit" value="Sign-Up" />
</form>
JavaScript
function construct() {
console.log("calling construct!");
var name = document.forms["form"]["name"].value;
var companyName = document.forms["form"]["companyName"].value;
var email = document.forms["form"]["email"].value;
var phone = document.forms["form"]["phone"].value;
var TimeForC = document.forms["form"]["TimeForContact"].value;
var availability = document.forms["form"]["aval"].value;
if (!validateExistence(name)) return false;
if (!validateExistence(companyName)) return false;
if (radioCheck() == false) return false;
if (phoneValidate(phone) == false) return false;
if (checkValidForOthers(TimeForC) == false || checkValidForOthers(availability) == false) return false;
if (emailCheck(email) == false) return false;
}
function validateExistence(name) {
if (!name) {
alert("You must enter a " + name + " to submit! Thank you.");
return false;
}
if (name.length > 40) {
alert(name + " is too long for our form, please abbreviate.");
return false;
}
return true;
}
function phoneValidate(phone) {
if (!phone || phone.length > 12 || isNaN(phone)) {
alert("Please enter a valid phone number.");
return false;
}
return true;
}
function checkValidForOthers(name) {
if (name.length > 40) {
alert(name + " is too long for our form, please abbreviate.");
return false;
}
return true;
}
function messageCheck(message) {
var currentLength = name.length;
var over = 0;
over = currentLength - 200;
if (name.length > 200) {
alert(name + " is too long for our form, please abbreviate. You are " + over + " characters over allowed amount");
return false;
}
return true;
}
function radioCheck() {
if (document.getElementById("yes").checked == false && document.getElementById("no").checked == false) {
alert("click yes or no");
return false;
}
return true;
}
function...