我有以下变量赋值验证用户输入的时间在谷歌表
function onEdit(e) {
if (e.range.getColumn() == 3){
var isValid = /^([0-1]?[0-9]|2[0-4]):([0-5][0-9])(:[0-5][0-9])?$/.test(e.value);
}
}
我试图测试是否当一个人编辑在谷歌电子表格的第三列中的值,该值是否他们进入是带AM或PM的HH:MM格式的有效时间。
我在互联网上发现了上述情况,但我从未见过这种理解时间的方式。有人可以解释我发生了什么,或者将我链接到关于上述语法如何工作的文章?
的希望最终能够做到这样的事情:
function onEdit(e){
if (the user edits manually edits a value in the third column){
determine whether the value they entered is a valid time
if it is{
let the change go through
}
if it is not{
alert("Sorry your change can't go through");
}
}
}
从我读的警报已经在正确的语法