Created
June 27, 2012 12:27
-
-
Save keroxp/3003750 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
(function(){ | |
$(function(){ | |
var __VARS__, | |
ID = $("#id").val(), | |
red = "#CD2525", | |
green = "#adff2f", | |
blue = "#1E90FF", | |
$input = $("#input1"); | |
$input.on("keydown keyup",checkID).val(ID).css("backgroundColor",green); | |
function checkID (e){ | |
var chars = this.value; | |
if(chars.length > ID.length){ | |
this.style.backgroundColor = red; | |
}else{ | |
for(var i = 0 , max = chars.length ; i < max ; i++){ | |
if(chars[i] != ID[i]){ | |
this.style.backgroundColor = red; | |
break; | |
} | |
if(chars.length == ID.length){ | |
this.style.backgroundColor = green; | |
}else{ | |
this.style.backgroundColor = blue; | |
} | |
} | |
} | |
} | |
}) | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment