我有这个问题:我有这个代码
if(ext!="rar") {
$('#myform').trigger('click');
}
如果所选文件的文件扩展名不是rar,则文件输入应再次打开窗口以选择另一个文件,但此代码似乎不起作用。我应该怎么办?
我有这个问题:我有这个代码
if(ext!="rar") {
$('#myform').trigger('click');
}
如果所选文件的文件扩展名不是rar,则文件输入应再次打开窗口以选择另一个文件,但此代码似乎不起作用。我应该怎么办?
$("#btn").click(function()
{
var fu = $("#fu");
var ext = /[^.]+$/.exec(fu.val());
if (ext!="rar")
{
fu.trigger("click");
}
});
Assuming that your form tag has the id myform
, what you have done just triggers a click on the form (not even on the submit button of the form). Without the HTML, it is not possible to know what you are triggering the click on.
What you need to do is trigger the click on the submit button
$('#mysubmitbutton').click();
or trigger a form submit:
$('#myform').submit();