Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我编写了一个 JavaScript 脚本并将其保存为外部文件,现在想在完成时调用它来验证表单条目(而不是整个表单)。我正在考虑使用onchangeand onblur,但找不到任何方法来做到这一点。我只是瞎了吗?
onchange
onblur
您还必须在 HTML 页面中包含外部脚本。假设您的外部脚本文件已命名my_external.js并包含一个名为 的函数my_external_function,则以下代码示例应该可以工作:
my_external.js
my_external_function
<html> <head> <script src="my_external.js"></script> </head> <body> <input type="text" onblur="my_external_function()" /> </body> </html>