HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ns3133907 6.8.0-86-generic #87-Ubuntu SMP PREEMPT_DYNAMIC Mon Sep 22 18:03:36 UTC 2025 x86_64
User: cssnetorguk (1024)
PHP: 8.2.28
Disabled: NONE
Upload Files
File: /home/mykensington.co.uk/public_html/ext_iframe/v2/resources/js/form_validations/additional.js
// Additional functions for form validations ================================================
// (wrong fields highlighting, showing-hiding errors, etc.) =================================

function do_stars(mode, objs) {         //show-hide stars near form-fields
    for (var i=0; i<objs.length; i++) {
        if (mode == 'hide') {
            document.getElementById(objs[i]).style.visibility = 'hidden';
        } else if (mode == 'show') {
            document.getElementById(objs[i]).style.visibility = 'visible';
        }
    }
}

function checkExtension(o, allowedExt) {            //check allowed extensions for input.type=='file'
    var allowedExtensions = allowedExt ? allowedExt : {doc : 1, rtf : 1, txt : 1};
    var extension = o.value.toLowerCase().replace(/[\'\"\s\t]*$/gi, '').match(/[^\.]*$/);
    if (typeof allowedExtensions[extension] == 'undefined') {
        return false;
    }
    return true;
}

function stuff(problemFields, form, focusOnly, addElement) {        //highlighting wrong fields
    if (problemFields.length) {
        if (typeof focusOnly=='undefined' || focusOnly==null) {
            for (var i=0; i<problemFields.length; i++) {
                var el = document.getElementById(problemFields[i]);
                el.style.backgroundColor = '#FDC0BD';
                el.style.border = 'solid 2px red';
            }
        }
        if (problemFields[0]) {
            if (!form.elements[problemFields[0]] && addElement) {
                form.elements[addElement].focus();
            } else {
                var fstEl = form.elements[problemFields[0]] ? form.elements[problemFields[0]] : document.getElementById(problemFields[0]);
                if (typeof fstEl.focus != 'undefined') {
                    fstEl.focus();
                    if (fstEl.type=='text' || fstEl.type=='textarea' || fstEl.type=='password') {
                        fstEl.select();
                    }
                } else {
                    fstEl.firstChild.focus();
                }
            }
        }
    }
}

function clear_highlight(obj) {             //clearing wrong field  (ONE FIELD)
    var o = document.getElementById(obj);
    if (o.style.backgroundColor != '') {
        o.style.backgroundColor = '';
        if (document.forms[gformName].elements[obj] || o.className.match(/divLikeSelect/i)) {
            var field = document.forms[gformName].elements[obj] ? document.forms[gformName].elements[obj] : o;
            field.style.borderStyle = 'inset';
            field.style.borderWidth = '2px 1px 1px 2px';
            field.style.borderColor = 'threedlightshadow';
        } else o.style.border = '';
    }
}

function clear_highlight_all(form) {        //clearing highlighting in all fields of the form
    for (var i=0; i<form.elements.length; i++) {
        var fEl = form.elements[i];
        if (fEl.type != 'hidden') {
            fEl.style.backgroundColor = '';
            fEl.style.borderStyle = 'inset';
            fEl.style.borderWidth = '2px 1px 1px 2px';
            fEl.style.borderColor = 'threedlightshadow';
        }
    }
}

function __reporter(form, errors) {         //error report
    var div = document.getElementById('floatWithResults');
    if (errors.length > 0) {
        if (!div || (div && div.style.display!='block')) alert(getReport(errors));
        return false;
    }
    return true;
}

function __cancel_selection(mode) {         //cancel the city entered when GEOsearch
    postcode_touchpoint.value = '';
}

function __disable_geo_search(form) {
    outcode_id_touchpoint.value = '';
    postcode_id_touchpoint.value = '';
}

/*  replaces all two near to each other standing whitespaces in a string with just one whitespace 
    Nick Pepper (c) 2006
*/
function removeDoubledWS(string) {          //yeremeiev: no _while()_ anymore
    var newStr = string.toString();
    var re = /(\s){2,}/g;
    return newStr.replace(re, " ");
}

function field_disabler(condition, flds) {
    for (var i=0; flds[i]; i++) {
        flds[i].disabled = (condition==true) ? true : false;
    }
}

String.prototype.postcodeToOutcode = function() {
    var pc = /([a-z]{1,2}\d[\da-z]?)\s*(\d[a-z]{2})/i;
    return (this.match(pc)) ? this.replace(pc,"$1 $2") : this;
}

function optional(elm, another) { // just to add '(optional)' to tips on mainpage
    switch (elm.name) {
        case 'keywords':
            if (elm.value.trim() != '') {
                if (kw_tip.lastChild == optnl) kw_tip.removeChild(kw_tip.lastChild);
                if (another.value.trim()=='' && loc_tip.lastChild!=optnl) loc_tip.appendChild(optnl);
            } else {
                if (another.value.trim()=='' && loc_tip.lastChild==optnl) loc_tip.removeChild(loc_tip.lastChild);
                if (another.value.trim()!='' && kw_tip.lastChild!=optnl) kw_tip.appendChild(optnl);
            }
            break;
        case 'postcode':
            if (elm.value.trim() != '') {
                if (loc_tip.lastChild == optnl) loc_tip.removeChild(loc_tip.lastChild);
                if (another.value.trim()=='' && kw_tip.lastChild!=optnl) kw_tip.appendChild(optnl);
            } else {
                if (another.value.trim()=='' && kw_tip.lastChild==optnl) kw_tip.removeChild(kw_tip.lastChild);
                if (another.value.trim()!='' && loc_tip.lastChild!=optnl) loc_tip.appendChild(optnl);
            }
            break;
    }
}