Skip to content

Instantly share code, notes, and snippets.

@dandiebolt
Created July 22, 2015 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dandiebolt/7dba391f831caa7d3175 to your computer and use it in GitHub Desktop.
Save dandiebolt/7dba391f831caa7d3175 to your computer and use it in GitHub Desktop.
(function(){
var querystring=document.location.search;
if(/a=er/i.test(querystring) || /nwr/i.test(querystring)) {
$(_fid_7).attr({
placeholder: "##-####(#)-####",
pattern: "[0-9]{2}-[0-9]{4,5}-[0-9]{4}"
});
$(_fid_8).attr({
placeholder: "#####-###",
pattern: "[0-9]{5}[-][0-9]{3}"
});
$(_fid_9).attr({
placeholder: "###.##",
pattern: "[0-9]{3}[.][0-9]{2}"
});
$(_fid_10).attr({
placeholder: "###.##",
pattern: "[0-9]{3}[.][0-9]{2}"
});
$(_fid_8).on("keyup", function(){
if ($(this).is(":invalid")) {
$(this).css("color", "red");
} else {
$(this).css("color", "#333");
}
});
$(_fid_7).on("blur", function(){
if ($(this).is(":invalid")) {
$(this).css("color", "red");
} else {
$(this).css("color", "#333");
}
});
var originalClickHandler = $("#saveButton")
.data("events").click[0].handler;
$("#saveButton").unbind("click");
$("#saveButton").click(function() {
var yours = parseFloat(_fid_9.value);
var mine = parseFloat(_fid_10.value);
if (yours > mine) {
_fid_9.value = mine;
_fid_10.value = yours;
}
originalClickHandler();
});
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment