내 Demo Jsfiddle랜덤 함수와 입력 값을 어떻게 같습니까?
내 코드
HTML을
<canvas id="random" title="Click to Change"></canvas>
<input name="rand" type="text" id="rand" data-filter="false"/>
<span id="rands"></span>
jQuery를
function Random() {
var length = 6,
charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
retVal = "";
for (var i = 0, n = charset.length; i < length; ++i) {
retVal += charset.charAt(Math.floor(Math.random() * n));
}
return retVal;
}
var ctx = document.getElementById("random").getContext('2d');
ctx.font = "50px Arial";
ctx.fillText(Random(), 0, 40);
$("#random").click(function() {
if($("#rand").val() !== Random()){
ctx.clearRect (0,0,1000,1000);
ctx.fillText(Random(), 0, 40);
}
});
$('#rand').bind('keypress keyup change', function() {
if ($(this).val() !== Random()) {
$(this).addClass('false').removeClass('true').attr('data-filter', 'false'), $("#" + this.id + "s").css({
"color": "#C41111"
}).text("Characters in conflict with each other!");
} else {
$(this).addClass('true').removeClass('false').attr('data-filter', 'true'), $("#" + this.id + "s").css({
"color": "#7FAC25"
}).text($(this).val() + " is accepted!");
}
});
내가이 if($("#rand").val() !== Random())
하지만 난 할 수 없습니다 동일한 싶어?
Tuerkçe olarak ben bu if içindeki functionu eşitleyemiyorum demoda görebilirinin nasıl yapacağm hakkında bilgisi olan var mı?
ASIL 델리 benim yahuu .. soru eskiymiş :) – Nihat