Skip to content

Instantly share code, notes, and snippets.

@dandiebolt dandiebolt/gist.js
Created Jul 22, 2015

Embed
What would you like to do?
(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
You can’t perform that action at this time.