我需要为此测试用例验证Textbox。
我试过了,
var input = document.getElementById('configMinute').value;
//console.info("Else Called");
var slashPattern = "/";
var specialChars = "<>@!#$%^&*()_+[]{}?:;|'\"\\,./~`-=";
var getStringCheck = checkSpecialChar(input,specialChars);
if(getStringCheck==true){
// string = 1,2,3,*/10
// ,*/
var getStringValues = input.split(',');
var notAllowedCharPattern = "<>@!#$%^&()_+[]{}?:;|'\"\\.~`-=";
var allowedChar = checkSpecialChar(input,notAllowedCharPattern);
if(allowedChar==false){
console.info(getStringValues);
getStringValues.forEach(function(element){
//string = 1 2 3 */10
var validateSlash = checkSpecialChar(element,slashPattern);
if(element.startsWith("*")==true){
var newInput = element.split('/');
console.info("newInput: "+ element);
newInput.forEach(function(element) {
console.info("newInput Foreach: "+ element);
if(element=='*' || (element>=0 && element <=59)){
return true;
}
else{
alert("Please enter numbers between 0 to 59 or '*' ==>1");
document.getElementById('configMinute').focus();
return false;
}
});
}else{
console.info("* Else: "+ element);
if(element=='*' || (element>=0 && element <=59)){
return true;
}else{
alert("Please enter numbers between 0 to 59 or '*' ==>1");
document.getElementById('configMinute').focus();
return false;
}
}
});
}else{
alert ("File name has special characters \nAllowed Characters are *,/ ==>3");
document.getElementById('configMinute').focus();
return false;
}
}else if(input == '*' || (input>=0 && input <=59)){
return true;
}else{
alert("Please enter numbers between 0 to 59 or '*' ==>4");
document.getElementById('configMinute').focus();
return false;
}
提前致谢
答案 0 :(得分:0)
你可以试试像
这样的正则表达式data.frame()
它匹配行的开头((?:(?:^|,)(?:[1-5]?\d|\*?\/59)\b)+$
)或^
,后跟数字0-59或,
,可选地前面有/59
。然后这个模式可以重复任意次,直到行结束。