我可以将exist javascript函数调用到jquery函数中吗
我可以创建一个jQuery函数来调用现有的Javascript函数吗。但是,该Javascript函数来自不同的文件 首先,我有一个按钮,可以打开包含表单的模态对话框。在表单弹出之前,我想先使用一个已经存在的函数来检查验证我可以将exist javascript函数调用到jquery函数中吗,javascript,jquery,jquery-ui-dialog,Javascript,Jquery,Jquery Ui Dialog,我可以创建一个jQuery函数来调用现有的Javascript函数吗。但是,该Javascript函数来自不同的文件 首先,我有一个按钮,可以打开包含表单的模态对话框。在表单弹出之前,我想先使用一个已经存在的函数来检查验证 <body> <input type="button" name="buttonform" id="buttonform" value="Open Modal Form" /> <div id="dialogform" align = "cen
<body>
<input type="button" name="buttonform" id="buttonform" value="Open Modal Form" />
<div id="dialogform" align = "center">
DIALOG
<form name="myForm2" action="/action_page.php" onsubmit="return validateForm()" method="post">
Name: <input type="text" name="fname">
<input type="submit" value="Submit">
</form>
</div>
</body>
顺便说一句,我是jQuery新手。谢谢 首先,在jQuery之后立即将js文件添加到HTML中
<html>
<head>
<script src="functionToUse.js"></script>
</head>
</html>
是的,您可以使用
checkheader()
而不是$(“#functioncheckheader”)
这样做,只要checkheader
是全局公开的。只要您使用
或
标记导入该文件,我明白了。再次感谢大家!自定义js应该在jquery.js include之后,因为它使用jquery
function checkheader(){
if($('#company').val() == 'select')
{ alert("Please select the date in header"); }
else if($('#project').val() == 'select')
{ alert("Please select the project in header"); }
else if($('#reqType').val() == 'select')
{ alert("Please select the request type"); }
else if($('#la').val() == "")
{ alert("Please fill up the LA no."); }
else if($('#workScope').val() == "")
{ alert("Please select the work scope."); }
}
<html>
<head>
<script src="functionToUse.js"></script>
</head>
</html>
$('#buttonform').click(function (){
funcFromFile(); //function to call from other javascript file
$('#dialogform').dialog('open');
});