为了账号安全,请及时绑定邮箱和手机立即绑定

如何在 if 条件内对 preg 匹配进行多变量控制?

如何在 if 条件内对 preg 匹配进行多变量控制?

PHP
茅侃侃 2023-03-04 14:32:35
我检查了 post 方法附带的输入。但是这个 if 条件代码不起作用。编辑:否则落在他的街区是JavaScript$(".inputonlytext").keypress(function(e) {    var key = e.keyCode;    if ((key >= 48 && key <= 57) || (key >= 33 && key <= 47) || (key >= 58 && key <= 64) || (key >= 91 && key <= 96) || (key >= 123 && key <= 127)) {        e.preventDefault();    }    /*if (e.which === 32)        return false; */    //var text = $(this).val();    //$(this).val(text.replace(" ", ""));});是输入<input type="text" name="name" class="form-control inputonlytext" maxlength="50" required="required"><input type="text" name="surname" class="form-control inputonlytext" maxlength="50" required="required">是PHP;if($_POST["name"] !== null && preg_match('/^[a-zA-Z ]+$/', $_POST["name"]) && $_POST["surname"] !== null && preg_match('/^[a-zA-Z ]+$/', $_POST["surname"])){            //true for my application logic. (think like a reverse)}else{            //false for my application logic. (think like a reverse)}
查看完整描述

1 回答

?
守着星空守着你

TA贡献1799条经验 获得超8个赞

这是另一种选择;

我用了

$_POST["name"] !== null

代替

isset($_POST["name"])


查看完整回答
反对 回复 2023-03-04
  • 1 回答
  • 0 关注
  • 75 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信