var AJAX = { XMLHttpFactories : [ function () {return new XMLHttpRequest()}, function () {return new ActiveXObject("Msxml2.XMLHTTP")}, function () {return new ActiveXObject("Msxml3.XMLHTTP")}, function () {return new ActiveXObject("Microsoft.XMLHTTP")} ], createXMLHTTPObject : function () { xmlhttp = null; for (var i=0;i= waitforlength){ sql = replaceAll(sql, '%23pin%23', elementvalue); queryparams = {"SQL": sql, "response":"1"}; execute_ajax_function("includes/incexecutesql.php", queryparams); //document.getElementById(divid).innerHTML = sql; } } } function numbersonly(e){ var key; var keychar; var result; if (window.event) key = window.event.keyCode; else if (e) key = e.which; else result = true; keychar = String.fromCharCode(key); if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) || (key==99) || (key==118)) result = true; else if ((("-.0123456789").indexOf(keychar) > -1)) result = true; else{ alert('Only digits allowed'); result = false; } return result; } function fsetreadOnly(elementid){ //alert(elementid); document.getElementById(elementid).checked = true; document.getElementById(elementid).readOnly = true; document.getElementById(elementid).disabled = true; } function fsetchecked(elementid, checked){ if(checked == 1){ checked = true; }else{ checked = false; } for (var i=0; i maxlength ){ alert ('"' + elementid + '" must be between ' + minlength + ' and ' + maxlength + ' in length'); document.getElementById(elementid).select(); document.getElementById(elementid).focus(); document.getElementById(elementid).style.background = 'red'; result = false; } } return result; } function fvalidatenumeric(elementid, minvalue, maxvalue){ var result = true; if(fiselement(elementid)){ var elementvalue = document.getElementById(elementid).value.trim(); elementvalue = parseFloat(elementvalue); minvalue = parseFloat(minvalue); maxvalue = parseFloat(maxvalue); if(elementvalue == '' || isNaN(elementvalue) ){ alert ('"' + elementid + '" must be a number'); document.getElementById(elementid).select(); document.getElementById(elementid).focus(); document.getElementById(elementid).style.background = 'red'; result = false; }else if(elementvalue < minvalue || elementvalue > maxvalue ){ alert ('"' + elementid + '" must be between ' + minvalue + ' and ' + maxvalue); document.getElementById(elementid).select(); document.getElementById(elementid).focus(); document.getElementById(elementid).style.background = 'red'; result = false; } } return result; } function fnotidentical(elementid1, elementid2, ignoreifempty){ if(isempty(ignoreifempty) || ignoreifempty == ''){ ignoreifempty = 0; } var result = true; if(fiselement(elementid1) && fiselement(elementid2)){ var elementvalue1 = document.getElementById(elementid1).value.trim(); var elementvalue2 = document.getElementById(elementid2).value.trim(); if(elementvalue1 == elementvalue2){ if(ignoreifempty == 0 || elementvalue1 != ''){ alert('"' + elementid1 + '" cannot be the same as "' + elementid2 + '"'); document.getElementById(elementid2).select(); document.getElementById(elementid2).focus(); document.getElementById(elementid2).style.background = 'red'; result = false; } } } return result; } function fidentical(elementid1, elementid2){ var result = true; if(fiselement(elementid1) && fiselement(elementid2)){ var elementvalue1 = document.getElementById(elementid1).value.trim(); var elementvalue2 = document.getElementById(elementid2).value.trim(); if(elementvalue1 != elementvalue2){ alert('"' + elementid1 + '" must be the same as "' + elementid2 + '"'); document.getElementById(elementid2).select(); document.getElementById(elementid2).focus(); result = false; } } return result; } function fpasswordcheckifnotempty(elementid, minlength, maxlength, minvalue, maxvalue){ var result = true; if(fiselement(elementid)){ var elementvalue = document.getElementById(elementid).value.trim(); if(elementvalue.length != 0){ result = fvalidatelength(elementid, minlength, maxlength); if(result){ result = fvalidatenumeric('tenantpin', minvalue, maxvalue); } } } return result; } function fpasswordcheck(elementid, minlength, maxlength){ var result = false; if(fiselement(elementid)){ var elementvalue = document.getElementById(elementid).value.trim(); result = fvalidatelength(elementid, minlength, maxlength); } return result; } function fpasswordcheckreset(elementid1, elementid2, minlength, maxlength){ var result = false; if(fiselement(elementid1) && fiselement(elementid2)){ result = fvalidatelength(elementid1, minlength, maxlength); if(result){ result = fidentical(elementid1, elementid2); } } return result; } function floginwithtestaccount(mobile, pin){ if(fiselement('mobile')){ document.getElementById('mobile').value = mobile; } if(fiselement('pin')){ document.getElementById('pin').value = pin; } } function replaceAll(txt, replace, with_this) { return txt.replace(new RegExp(replace, 'g'),with_this); } function rollTidOver(meter_id, account_id, user_id) { if (confirm('Are you aware of the Process of entering the TID tokens for account (' + account_id +')?')) { // 1502 if (confirm('Have you used all previous credit tokens bought or generated?')) { // 1503 if (confirm('Are you sure you want to proceed with the changes? Remember to enter the tokens in the correct sequence.')) { // 1504 - submit to generate kct & test token $.ajax({ type: "POST", url: '221.generate_tokens.php?meter_id='+ meter_id +'&user_id='+ user_id +'&token='+ $('#urltoken').val(), beforeSend: function() { $("#imgSpinner1").show(); }, complete: function() { $("#imgSpinner1").hide(); }, success: function(response){ location.reload(); }, error: function(xhr, status, error){ console.log(response); console.error(xhr); } }); } } } else { confirm('Test Department to provide Link Watch Here.') } }