﻿
// creating a new validation method that can be used for validating any form element.
// this one requires the text to be hexidecimal with a # at the start.
$.validator.addMethod("hexidecimal", function(value) {
	return /^(#){1}([a-fA-F0-9]){6}$/.test(value);
}, 'Valid Hexidecimal Color Code Required (e.g. #CCCCCC)');



$.validator.addMethod("phoneUS", function(phone_number, element) {
    phone_number = phone_number.replace(/\s+/g, "");
    return this.optional(element) || phone_number.length > 9 &&
		phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
}, "Please specify a valid US phone number");



$.validator.addMethod("selectionmade", function(selection_made, element) {
    return this.optional(element) || (selection_made != "-1" && selection_made != "NotApplicable" && selection_made != "-99");
}, "Please make a selection");
