IUG FORUM

Stay always connected!
  1. Joanna Waggoner
  2. Sierra/ Millennium/ Encore
  3. Tuesday, 21 June 2016
  4.  Subscribe via email
Would someone be willing to share their code for the patron self-registration form with javascript extras, such as field validation, required fields, form completion error message, etc. (I am not actually sure what is possible!) Thank you!
Comment
There are no comments made yet.
Accepted Answer Pending Moderation
0
Votes
Undo
I also need some help with validation of our self-registration form. I need to validate the Zip Codes for my library service area. Here's what III gave me:
<script type="text/javascript">
function selfRegChecker() {
var regForm = document.getElementsByTagName("INPUT";);
var messageDiv = document.getElementById("selfRegMessage";);
for (i = 0; i < regForm.length; i++) {
switch (regForm[i].id) {
case "nfirst":
if (regForm[i].value == null || regForm[i].value == "";) {
var message = document.createTextNode("Oops... Please supply your First Name to Register.";);
messageDiv.innerHTML = "";
messageDiv.appendChild(message);
regForm[i].focus();
return false;
}
break;
case "nlast":
if (regForm[i].value == null || regForm[i].value == "";) {
var message = document.createTextNode("Oops... Please supply your Last Name to Register.";);
messageDiv.innerHTML = "";
messageDiv.appendChild(message);
regForm[i].focus();
return false;
}
break;
case "stre_aaddress":
if (regForm[i].value == null || regForm[i].value == "";) {
var message = document.createTextNode("Oops... Please supply your Address to Register.";);
messageDiv.innerHTML = "";
messageDiv.appendChild(message);
regForm[i].focus();
return false;
}
break;
case "city_aaddress":
if (regForm[i].value == null || regForm[i].value == "";) {
var message = document.createTextNode("Oops... Please supply your City to Register.";);
messageDiv.innerHTML = "";
messageDiv.appendChild(message);
regForm[i].focus();
return false;
}
break;
case "stat_aaddress":
if (regForm[i].value == null || regForm[i].value == "";) {
var message = document.createTextNode("Oops... Please supply your State to Register.";);
messageDiv.innerHTML = "";
messageDiv.appendChild(message);
regForm[i].focus();
return false;
}
break;
case "nlast":
if (regForm[i].value == null || regForm[i].value == "";) {
var message = document.createTextNode("Oops... Please supply your Last Name to Register.";);
messageDiv.innerHTML = "";
messageDiv.appendChild(message);
regForm[i].focus();
return false;
}
break;
case "post_aaddress":
if (regForm[i].value == null || regForm[i].value == "";) {
var message = document.createTextNode("Oops... Please supply your Zip Code to Register.";);
messageDiv.innerHTML = "";
messageDiv.appendChild(message);
regForm[i].focus();
return false;
}
break;
}
}
return true;
}
</script>-->

elizabeth.gray@yolocounty.org
Comment
There are no comments made yet.
  1. more than a month ago
  2. Sierra/ Millennium/ Encore
  3. # 1
Accepted Answer Pending Moderation
0
Votes
Undo
I'm not an expert, but I'll share what I created last year. I learned everything on the fly (and it's no looker), but it gets the job done. I'll paste just the pieces involved in the zip code checker below, and you can pull the rest of the code from our form: http://dcls.iii.com/selfreg

The special handling built into our page includes:

Birth date checking (Only valid dates allowed; no future dates)
Birth date formatting (Sierra is picky about date formats)
Age checking (if birthdate shows age under 18, Guardian field is required)
Force phone formatting
Check zip codes (use the zip from h-tagged address if present; otherwise use zip from a-tagged address)
Write unmappable fields to Sierra d field (Guardian name, Notice Preference, Home Library)
Require acceptance of user agreement





// residency checker
var hZip = post_haddress2.value
var aZip = post_aaddress.value

if(hZip != "";){
var zip = hZip
} else {
var zip = aZip
};

var serviceArea = [
//Dauphin County
"17005", //Berrysburg
"17017", //Dalmatia
"17018", //Dauphin
"17020", //Duncannon
"17022", //Elizabethtown
"17023", //Elizabethville
"17028", //Grantville
"17030", //Gratz
"17032", //Halifax
"17101", //Harrisburg
"17102", //Harrisburg
"17103", //Harrisburg
"17104", //Harrisburg
"17109", //Harrisburg
"17110", //Harrisburg
"17111", //Harrisburg
"17112", //Harrisburg
"17113", //Harrisburg
"17120", //Harrisburg
"17033", //Hershey
"17034", //Highspire
"17036", //Hummelstown
"17048", //Lykens
"17057", //Middletown
"17061", //Millersburg
"17078", //Palmyra
"17080", //Pillow
"17980", //Tower City
"17097", //Wiconisco
"17098", //Williamstown
//Cumberland County
"17307", //Biglerville
"17007", //Boiling Springs
"17011", //Camp Hill
"17013", //Carlisle
"17015", //Carlisle
"17019", //Dillsburg
"17025", //Enola
"17324", //Gardners
"17027", //Grantham
"17043", //Lemoyne
"17053", //Marysville
"17050", //Mechanicsburg
"17055", //Mechanicsburg
"17065", //Mount Holly Springs
"17070", //New Cumberland
"17072", //New Kingstown
"17240", //Newburg
"17241", //Newville
"17081", //Plainfield
"17257", //Shippensburg
"17093", //Summerdale
"17266", //Walnut Bottom
//Perry County
"17006", //Blain
"17020", //Duncannon
"17021", //East Waterford
"17024", //Elliotsburg
"17035", //Honey Grove
"17037", //Ickesburg
"17040", //Landisburg
"17045", //Liverpool
"17047", //Loysville
"17053", //Marysville
"17062", //Millerstown
"17068", //New Bloomfield
"17069", //New Buffalo
"17071", //New Germantown
"17074", //Newport
"17090" //Shermans Dale
];


if(serviceArea.includes(zip)===false){
var message = document.createTextNode("Sorry, there was a problem. You must live in our Service Area to register online.";);
messageDiv.innerHTML ="";
messageDiv.appendChild(message);
document.getElementById("post_aaddress";).focus();
return false;
}

ahunsberger@dcls.org
Comment
There are no comments made yet.
  1. more than a month ago
  2. Sierra/ Millennium/ Encore
  3. # 2
  • Page :
  • 1


There are no replies made for this post yet.
Be one of the first to reply to this post!