1

特殊文字を入力して、ユーザー名の入力フィールドを検証したい:

!`@#$%^&*()+=-[]\\\';,./{}|\":<>?~_

これが私のコードです:

function specialcharecter()
{
    var iChars = "!`@#$%^&*()+=-[]\\\';,./{}|\":<>?~_";   
    var data = document.getElementById("txtCallSign").value;
    for (var i = 0; i < data.length; i++)
    {      
        if (iChars.indexOf(data.charAt(i)) != -1)
        {    
            alert ("Your string has special characters. \nThese are not allowed.");
            document.getElementById("txtCallSign").value = "";
            return false; 
        } 
    }
}
4

0 に答える 0