javascript - 为什么在新窗口打开时提交表单?

标签 javascript jquery html

嗨,我有 javascript 函数来打开一个新窗口,并根据选择的值填充父窗口字段。但问题是在打开新窗口时提交了表单。我只是没有附加验证部分。谁能告诉我可能是什么问题吗?

$(function() {
//Popup window for Nationlity 
function nationalityPopUp() {
        var nationalUrl="%bind(:9)";
	    new_Window = window.open(nationalUrl,"","width=220, height=500, left=250, top=50, scrollbars, resizable"); 
}
  
//Disable Parent Window
function parent_disable() {
	if(new_Window && !new_Window.closed){ 
		new_Window.focus(); 
	}
} 
<body onclick="parent_disable();">
	<form name="Basicinfo" id="Basicinfo" method="post" action="%bind(:8)" onsubmit="return validateForm();">

      	<input type="text" name="Nationality" id="Nationality" value ="" />
                <input type="image" src="%bind(:14)" name="Ntlylkp" onclick="nationalityPopUp();"  />
               </br></br>*Country Of Residency:            	 				
   				<input type="text" name="Residency_country" id="Residency_country" value ="" onblur="validateResCountry(value)"/>
				<input type="image" src="%bind(:14)" name="Cntrylkp" onclick="countryPopUp();"/>
                </br></br>*National Id:
 			    <input id="Emirates_Id" name="Emirates_Id" type="text" value=""  style="margin-left:10px;">
              </br></br>*Marital Status:
            	<select name="marital_status" id="marital_status">
				  :%bind(:3);
                </select>            
            </br> </br> *Regional Preference:
            	<select name="religious" id="religious">
				  :%bind(:4);
                </select>
<input type="Submit" value="Submit And Next" style="float:right" >

</form>
</body>

最佳答案

return false 当使用 jquery 提交 for 时 -

$('#Basicinfo').on('submit', function() {
     if (some check needed) { // if want to add any check to submit the form or not
         return false;
     }
})

关于javascript - 为什么在新窗口打开时提交表单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30167402/

相关文章:

javascript - 我的 ajax 代码显示评论时出现问题

javascript - 水平翻转 .​​getUserMedia 的网络摄像头图像流

javascript - 使用当前的 jQuery Cycle 幻灯片更新 DIV 内容

javascript - ng-repeat 内的 ng-switch 不起作用

javascript - 使用ajax无需刷新页面即可显示数据库记录

javascript - 创建动态链接下拉菜单

jquery - 功能很慢,有没有更快的方法? (使用 jQuery 1.4.2)

php - 如何在更改时更新所选选项元素的总和

html - 带有 Neon 样式 css 的左右边框

html - 最小宽度不适用于表格布局 :fixed