Special character validation using JavaScript

前端 未结 5 1567
不思量自难忘°
不思量自难忘° 2021-01-15 02:48

Special characters <, >, %, \'\', \"\", $ and ^ are not allowed in a textbo

5条回答
  •  滥情空心
    2021-01-15 03:20

    function isSpclChar(){
    var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
    for (var i = 0; i < document.qfrm.q.value.length; i++) {
        if (iChars.indexOf(document.qfrm.q.value.charAt(i)) != -1) {
        alert ("The box has special characters. \nThese are not allowed.\n");
        return false;
            }
        }
    }   
    

提交回复
热议问题