Field Validator

PowerSchool 7.2 now includes Data Validation for the Students/Teachers tables.

State reporting needs, among others, are rising. With them is an increased need for schools to rely on multiple sources of input for that state reporting. Problem is the more people who are involved in inputting the data the bigger the chance that things are going to get entered incorrectly. Pearson is starting to make things a little easier but its not quite enough yet. So we created a script you can use (and expand) to make things a little easier.

This customization is a script to use on pages you want to validate user input AS they are imputing it and again when they submit. Why both? Validating a field as they enter it will help catch errors as they are happening. Validating on submission will help catch errors that were already on the page that the user hadn't entered. What's more is the simple functions are made generic to allow the user to reuse them across many pages.

Included in the package is a sample of how to use the validations. The /admin/students/generaldemographics.html page should only be used as an example but if you have no customizations on that page already you could use this and it should work.

To use (all):
Add the script to the header of the page

To use to validate as the user enters:
For the field that you want to validate use the onBlur action to reference the appropriate validation(s). Each of the functions will strip out any leading or trailing spaces and will replace multiple spaces with a single space. If the user has entered incorrectly formatted data the user will be sent a message and put back into the field to fix the error
* As of 3/20/2012 there is an error getting the script to return to the problem field when the user is using Firefox 11. We're looking for a resolution and will update if/when we find one.
See examples on the sample page.

To use to mass validate on submit:
Create a function on the page in the header. This function should call each of the validations that you wish to perform. From here you can also call the function to trim the field of any entry field you don't want to allow the user to enter random spaces.
To trigger the function call it using the onSubmit action in the Form.
See example on the sample page

This is not a complete list and we are taking recommendations if there is a common validation you think people can use please let us know. Also note that the sample page contains a 2nd mailing address to demonstrate the validation of a non-mandatory address. You may want to remove this or alter it to your needs.

Files:
/scripts/fieldValidator.js
/admin/students/generaldemographics.html (optional)

Customization:

Contributor: 
Jason Treadwell
CPM Import Friendly: 
Y

Comments

Hey Jason, this is what I found to solve the problem. There's probably a cleaner way to do it though:
setTimeout(function() {document.getElementById(field).focus();document.getElementById(field).select();}, 1);

Thanks Ben, it does seem to work. Going to test it on other browsers just to make sure then I'll upload the updated script.

Jason Treadwell
Custom Solutions Specialist
jason@powerdatasolutions.org
www.powerdatasolutions.org

Tisk Tisk Jason, where's the jQuery goodness?

It would be really cool and helpful if users were not allowed to click submit if the "Current ELA Status Start Date" is not populated when the "Current ELA Status" is set to EL, IFEP, RFP, or TBD.

That is something you could do with this. You'll notice the example page validates 2 ways.

1. Validate as a user leaves the field. If the user has data that doesn't fit the rules you put in place then it puts the user back to the field to fix it.

2. Validate as the user submits. This is a bigger one and can be more complex. This is where you'd want to do that sort of check. If current_ela is not blank AND current_ela_status is blank then fail. Those aren't your fields i'm sure and that's not code but its the idea.

Jason Treadwell
Custom Solutions Specialist
jason@powerdatasolutions.org
www.powerdatasolutions.org

What's the correct syntax if we want the phone number to validate the area code with parenthesis?
example (123) 456-7890

nervemind. got it

Tysha
Marion Community Schools
Marion, IN

Hi,

I'm struggling trying to verify that a box has been checked before Submit is allowed.
The field is in a Student Extended table. I get the alert message even if the box gets checked.

This is what I have at the end, just before </form>:

<table border="0" cellspacing="0" cellpadding="4">
<tr class="headerrow" align="center">
<td><input type="checkbox" id="parentsubmitted" name="[Students.U_Parent_Updates]submitted_permissions" value="1" checked onChange="setParentVerified()" />I acknowledge these permission Settings</td>
</tr>
</table>
<div class="button-row">
<input type="hidden" name="ac" value="autosendupdate" />
<button type="submit" value="Submit">Submit</button>
</div>

This is what I have for scripts:
<SCRIPT LANGUAGE="JavaScript">
function setParentVerified() {
document.getElementById("parentsubmitted").value=1;
var $j = jQuery.noConflict();
var currentTime = new Date();
var monthChanged = currentTime.getMonth() + 1;
var dayChanged = currentTime.getDate();
var yearChanged = currentTime.getFullYear();
var trimUser = $j.trim($j('#parentName').val());
var hourChanged = currentTime.getHours();
var minChanged = currentTime.getMinutes();
minChanged = minChanged > 9 ? minChanged : '0' + minChanged;
document.getElementById("whoChanged").value = trimUser + ' on ' + monthChanged + '-' + dayChanged + '-' + yearChanged
+ ' at ' + hourChanged + ':' + minChanged;

}
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
function verify() {

var themessage = "You must approve before submitting \n";
var anerror = true;
var parapp = document.getElementById("parentsubmitted").value
if (parapp == 1) {
anerror = true;
} else {
anerror = false;
}
//alert
if (anerror) {
alert(themessage);
return false;
} else {
return true;
}
}
</SCRIPT>

Naomi Doughty
SIS Coordinator

Hi Jason,

I know this is an older thread but I think I might be able to use this logic as a good starting point for Data Validation for our log entries, as well as a few other pages. The only burning question I have is if I can get any insight as to how I can validate the date selected to not be a future date.

I know that JS would be involved but since there was no example from the generaldemographics.html file would you be able to give an example as to what that would look like?

Is it a matter of just comparing the name="[08]Discipline_IncidentDate" > today or is there additional coding needed?

Thanks,

Tim Homa
Information Technology Manager

Subscribe to Comments for "Field Validator"