Last active
March 21, 2017 15:39
-
-
Save helloGoGo/b1a762b865e8dabf6d4290e64dc84394 to your computer and use it in GitHub Desktop.
入力値から前後の空白を削除してフィールドに再セット
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>trim</title> | |
<!--jQuery--> | |
<script src="../library/jquery/jquery-3.1.1.min.js"></script> | |
<script> | |
$(function(){ | |
/** | |
* 入力値から前後の空白を削除してフィールドに再セット | |
*/ | |
$('input').blur(function () { | |
var value = $(this).val(); | |
$(this).val($.trim(value)); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<input type="text" name="first_name"/> | |
<input type="text" name="last_name"/> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment