JSFiddle - React, Tailwind, and code Playground
HTML
<div id="register" class="grid_12">
<div id="insideregister" class="grid_12margin">
<div class="constrain">
<div class="elegantaeroregister registermargin">
<h1>New Customer Registration.</h1>
<h6>Please fill in the form below.</h6>
<h3>Please Read - We are currently experiencing a number of issues with this form.</h3><p> If the page refreshes on submit please make sure that your password is at least 6 characters long and includes 1 uppercase letter and 1 number (e.g. Password5). Also make sure the phone number is in this format: 01223750000. On this note, we would like to apologise for any inconvenience this may cause and if you are still experiencing problems, please use the support tab or call us on 01223750000. </p>
<% if error %><p class='error'>An internal error occurred! Please try again later</p><% end %>
<form accept-charset='utf-8' method='post' name="form" action='register' class="registerform" onsubmit="return validate_form()">
<h3 class="registernospace">Contact Information</h3>
<table>
<tbody>
<tr><th class="registerrowspace">Salutation</th><td class="registerrowspace"> <%= field('salutation') %> </td></tr>
<tr><th class="registerrowspace">First Name(s)</th><td class="registerrowspace"><%= field('name:first') %></td></tr>
<tr><th class="registerrowspace">Surname</th><td class="registerrowspace"><%= field('name:last') %></td></tr>
<tr><th class="registerrowspace">Organisation Type</th><td class="registerrowspace registeroraganisationtype"> <%= field('org-type') %> </td></tr>
<tr><th class="registerrowspace">Organisation Name</th><td class="registerrowspace"><%= field('org-name') %></td></tr>
<script type='text/javascript'>
toggle_org_name();
</script>
<tr><th class="registerrowspace">First Line of Address</th><td class="registerrowspace"><%= field('address') %></td></tr>
<tr><th class="registerrowspace">Second Line of Address</th><td...
JavaScript
<script type="text/javascript">
function check_form()
{
var passw = document.getElementById('password1').value;
/*if(passw.value != ""/* && form.password.value == form.pwd2.value) {*/
if(passw.value.length < 6 ) {
alert("Error: Password must contain at least six characters!");
form.password.focus();
return false;
}/*}*/
return true;
}
</script>
<script type='text/javascript'>
function validate_form() {
// Check the terms and conditions have been accepted.
var checkbox = document.getElementsByName('terms-accepted').item(0);
if(!checkbox.checked) {
alert('You cannot register unless you accept our terms and conditions.');
return false;
}
//passwordtry
/*var pass = document.getElementsByName('password');
if(pass.length < 6){
alert("Please enter valid password");
return false;
}*/
// Must have a county entered. Could be NA if not applicable.
if(document.getElementById('address:county-input-0').value == '') {
alert('Please enter your county, or enter "NA" if not applicable.');
return false;
}
var correct_phone_format_desc = "The Telephone Number should be formatted:\n'+CCC.NNNNNNNNNN'\nwhere CCC is your country code and NN.. is your phone number.\ne.g. '+34.120120120'.";
var default_phone = document.getElementById('phone:default-input-0').value;
if(!default_phone.match(/^[+.0-9 \-]+$/)) {
alert(correct_phone_format_desc);
return false;
}
if(document.getElementById('address:country-select-0').value == 'GB') {
// Check that this looks like a UK postcode.
var postcode = document.getElementById('address:postcode-input-0').value;
if(postcode.length < 5) {
alert("The postcode entered is not long enough.");
return false;
}
if(!postcode.match(/[a-zA-Z]/)) {
if(!postcode.match(/^[a-zA-Z]/)) {
alert("A postcode must begin with a letter.");
return false;
}
alert("A postcode must...