It's important to avoid binding events in the way you're currently doing it. Instead, consider using element.addEventListener
.
If your goal is to validate a form before submission, here's the correct approach:
document.querySelector("form").addEventListener("submit",function(){
// Validate your fields - use numericField() on both input fields
// If numericField returns true or false, the submit action will be cancelled if validation fails
return numericField(your_element);
});
To trigger a blur event on a specific element, you can use this code:
var el = document.querySelector("<select your element here>");
el.focus();
el.blur();
In HTML5, you can also perform direct validation of input fields on blur by correctly defining the type (e.g. number for Number inputs) and/or using the pattern
attribute. This allows browsers to trigger intrinsic validation upon blur.