Hi Team,
We are trying to assign zipcode validation for web application in adobe campaign classic.
Requirement :
User should enter only the zipcode which are in zipcode schema, then only form should get submitted otherwise it should provide an alert with please enter valid zipcode.
In javascript of the HTML page we are using this zipcode to get all the zipcodes from the schema and store it in the array.
Below is the code
var allpincodes2 = [<% for each(var rec in new XML(xtk.queryDef.create(<queryDef schema="schemaname" operation="select" lineCount="50000"> <select> <node expr="@ZIPCODE" alias="ZIPCODE"/> </select> </queryDef>).ExecuteQuery().toXMLString())){ %>
"<%= rec.toString().replace("<S_ZIPCODE><ZIPCODE>","").replace("</ZIPCODE></S_ZIPCODE>","") %>", <% } %> ];
$(document).ready(function () {
$(".pincode").change(function ()
{
var value = document.getElementById("pincode").value;
const filtered = allpincodes2.filter(word => word === value);
if(filtered.length == 0){
alert("Please select a zipcode from the provided zipcode list");
document.getElementById('pincode').value=null;
}
console.log(filtered);
});
});
// ]]></script>
Issue with the web page:
Loading time is around 15 seconds for the webpage, since it tries to assign all 47000 records from the schema to the array.
Hard coded values to the array takes around 7 to 8 seconds.
Required solution
Is there any other approach to bring the webpage loading time to 1 to 2 seconds?
Or
Can any one suggest different approaches to the validation of the zipcodes in text box?
Thanks,
Sachin C S