Last active
October 7, 2016 07:36
-
-
Save tag1216/409f365829bb7da39b3d925c0f9399a0 to your computer and use it in GitHub Desktop.
フォームに変更がないときはsubmit不可
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
$(function() { | |
$("form :submit").prop("disabled", true); | |
var getValues = function() { | |
return $("form :input").map(function() { | |
return $(this).val(); | |
}).get(); | |
} | |
var oldValues = getValues(); | |
$("form :input").on("change keyup dp.change", function() { | |
var newValues = getValues(), | |
changed = newValues.some(function(e, i) { return e != oldValues[i] }); | |
$("form :submit").prop("disabled", !changed); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment