GET IN TOUCH
@keyframes slideDownFadeIn{
from{opacity:0;transform:translateY(-4px)}
to{opacity:1;transform:translateY(0)}
}
.validation-error-message{
color:#D8000C;
font-size:.85em;
margin-top:6px;
display:block;
animation:slideDownFadeIn .2s ease-out forwards
}
.elementor-field.validation-error,
textarea.validation-error{
border-color:#D8000C!important;
box-shadow:0 0 4px rgba(216,0,12,.4)
}
window.addEventListener('load',function(){
const form = document.querySelector('.elementor-form[name="New Form"]');
if(!form) return;
form.setAttribute('novalidate','true');
/* ------------ REGEX RULES ------------ */
const validationRules = {
'form-field-ct_fName':{
regex:/^[a-zA-ZÀ-ÿ' -]{2,35}$/,
message:'Please enter a valid first name.'
},
'form-field-ct_lName':{
regex:/^[a-zA-ZÀ-ÿ' -]{2,35}$/,
message:'Please enter a valid last name.'
},
'form-field-ct_pNumber':{
regex:/^+?[0-9s().-]{10,18}$/,
message:'Please enter a valid phone number.'
},
// max 2 dots before @
'form-field-ct_email':{
regex:/^[a-zA-Z0-9_%+-]+(.[a-zA-Z0-9_%+-]+){0,2}@[a-zA-Z0-9-]+(.[a-zA-Z0-9-]+)*.[a-zA-Z]{2,}$/,
message:'Please enter a valid email address.'
},
'form-field-ct_city':{
regex:/^[a-zA-ZÀ-ÿs.'-]{2,50}$/,
message:'Please enter a valid city name.'
},
'form-field-ct_zCode':{
regex:/^d{5}(-d{4})?$/,
message:'Please enter a valid ZIP code.'
}
};
const liveRegion = document.createElement('div');
liveRegion.setAttribute('aria-live','assertive');
liveRegion.setAttribute('role','alert');
liveRegion.style.position='absolute';
liveRegion.style.left='-9999px';
form.appendChild(liveRegion);
function clearAllErrors(){
form.querySelectorAll('.validation-error-message').forEach(e=>e.remove());
form.querySelectorAll('.validation-error').forEach(f=>f.classList.remove('validation-error'));
}
function clearFieldError(field){
const group = field.closest('.elementor-field-group');
const msg = group.querySelector('.validation-error-message');
if(msg) msg.remove();
field.classList.remove('validation-error');
}
function showError(field,message){
const group = field.closest('.elementor-field-group');
if(group.querySelector('.validation-error-message')) return;
field.classList.add('validation-error');
const error = document.createElement('span');
error.className = 'validation-error-message';
error.textContent = message;
group.appendChild(error);
liveRegion.textContent = message;
}
function scrollToFirstError(){
const firstError = form.querySelector('.validation-error');
if(firstError){
firstError.scrollIntoView({behavior:'smooth',block:'center'});
firstError.focus({preventScroll:true});
}
}
Object.keys(validationRules).forEach(id=>{
const field = document.getElementById(id);
if(!field) return;
field.addEventListener('input',function(){
if(field.classList.contains('validation-error')){
clearFieldError(field);
}
});
});
const submitBtn = form.querySelector('button[type="submit"]');
submitBtn.addEventListener('click',function(e){
clearAllErrors();
let isValid = true;
Object.keys(validationRules).forEach(id=>{
const field = document.getElementById(id);
const rule = validationRules[id];
if(!field) return;
const value = field.value.trim();
// required empty
if(field.required && value===''){
isValid=false;
showError(field,'This field is required.');
return;
}
// regex fail
if(value!=='' && !rule.regex.test(value)){
isValid=false;
showError(field,rule.message);
}
});
if(!isValid){
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
scrollToFirstError();
return false;
}
});
});
Contact Blue Springs Foundation Repair
Our Services
- Concrete Slab Foundation Repair
- Basement Wall Repair
- Elevated Pilings or Stilts Foundation Repair
- Basement Waterproofing
- Cracked Wall / Structural Repair
- Drainage Services and Repair
- House Raising / Lifting
- House Leveling
- Mud Pumping
- Mudjacking / Slabjacking
- Retaining Wall Repair
- Root Barrier
- Polyurethane Foam Injection
- Commercial Foundation Repair
- Compaction Grouting
- Steel Push Pier Installation
- Slab Pier Installation
- Helical Pier Installation
- Pre-Construction Pier Installation
- Garage Lintel Repair