File type validation with Javascript

后端 未结 8 909
梦谈多话
梦谈多话 2020-12-09 22:52

I have a question regarding to JavaScript validation. I am validaing the whenever my scripts runs, it validates but also the action

8条回答
  •  余生分开走
    2020-12-09 23:12

    var fname = "the file name here.ext";
    var re = /(\.jpg|\.jpeg|\.bmp|\.gif|\.png)$/i;
    if (!re.exec(fname)) {
      alert("File extension not supported!");
    }

提交回复
热议问题