I have written a JavaScript script and saved it as an external file, and now want to call it to validate a form entry (not the whole form) when they finish. I was thinking of using onchange
and onblur
, but can't find any way to do this. Am I just being blind?
You would have to include the external script in your HTML page as well. Assuming your external script file is named my_external.js
and contains a function named my_external_function
, the following code sample should work:
<html>
<head>
<script src="my_external.js"></script>
</head>
<body>
<input type="text" onblur="my_external_function()" />
</body>
</html>