Created
June 22, 2012 10:45
-
-
Save honbin/2972021 to your computer and use it in GitHub Desktop.
ajaxzipの引数thisをディープコピーしてvalueの値を半角数値にして返す
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
(function($) { | |
convertHalfwidthNum = function(obj) { | |
var cObj = $.extend(true, {}, obj); | |
var str = ''; | |
var v = cObj.value; | |
var len = v.length; | |
for (var i = 0; i < len; i++) { | |
var c = v.charCodeAt(i); | |
if ((c >= 65296 && c <= 65305)) | |
str += String.fromCharCode(c - 65248); | |
else if(v.charAt(i).match(/\d+/g)) | |
str += v.charAt(i); | |
} | |
cObj.value = str; | |
return cObj; | |
} | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment