string testing fails
-
:confused: This code:
var allowedChars = "qwertyuiopasdfghjklzxcvbnm1234567890/'קראטוןםפךלחיעכגדשזסבהנמצ";
var card = document.getElementById("cardid").value; for (i=0; i< 10; i++) if (allowedChars.indexOf(card\[i\]) == -1) { alert("Error"); return true; }
is supposed to check an input string. For an unknown reason, it works on ff 3.6.10, but not on IE 7. Help will be highly appreciated. Thanks, Summer Bulb.
-
:confused: This code:
var allowedChars = "qwertyuiopasdfghjklzxcvbnm1234567890/'קראטוןםפךלחיעכגדשזסבהנמצ";
var card = document.getElementById("cardid").value; for (i=0; i< 10; i++) if (allowedChars.indexOf(card\[i\]) == -1) { alert("Error"); return true; }
is supposed to check an input string. For an unknown reason, it works on ff 3.6.10, but not on IE 7. Help will be highly appreciated. Thanks, Summer Bulb.
I don't think you can use
card[i]
to refernce the i'th character in a string this way, not in IE anyway. Try
card.charAt(i)
instead.
-
:confused: This code:
var allowedChars = "qwertyuiopasdfghjklzxcvbnm1234567890/'קראטוןםפךלחיעכגדשזסבהנמצ";
var card = document.getElementById("cardid").value; for (i=0; i< 10; i++) if (allowedChars.indexOf(card\[i\]) == -1) { alert("Error"); return true; }
is supposed to check an input string. For an unknown reason, it works on ff 3.6.10, but not on IE 7. Help will be highly appreciated. Thanks, Summer Bulb.
why you do not use regular expression?
//sorry, but I can not input the rest chars.
var reg=/[qwertyuiopasdfghjklzxcvbnm1234567890]{10}/gi;if(!reg.test(document.getElementById("cardId").value)){
alert("Error");
}see more javascript skill, just click moocr.com