20210317

メールアドレスの正規表現チェックとSRAリンク取得

テキストボックスに入力されたメールアドレスが正規表現にマッチしているか確認

var regex = /^[a-zA-Z0-9_.+-]+@([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]*\.)+[a-zA-Z]{2,}$/;
//以下ボタンクリック時に実行する関数中
email = $("#email")[0].value;
if (!(regex.test(email))) {
  console.log("incorrect email address");
  return
}

サーバに送られたメールアドレスが正規表現にマッチしているかを確認

router.post('/upload', function (req, res, next) {
  var regex = /^[a-zA-Z0-9_.+-]+@([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]*\.)+[a-zA-Z]{2,}$/;
  if (!(regex.test(req.body.email))) {
      console.log("incorrect email address");
      return
  }
  //res.render('uploaded');
  console.log(req.body);  
});
  • 20210317.1615957559.txt.gz
  • 最終更新: 2021/03/17 05:05
  • by 133.11.144.10