Hi,
I am writing a form validation script. I am new to javascript and from what I have read, it’s best practice to put your javascript in a separate file from your HTML.
If my validation script detects that a field is empty, I want it to output a warning message right above the form fields on the webpage. I have the form call a function using onSubmit. When the script uses document.write, it is putting the warning on a new webpage instead of putting the warning above the form itself.
Is it even possible to do this or in this case will I need to keep the javascript within the same file as the form (.htm in this case). I have done some searching but haven’t found anything useful so far.
I know I have seen this done on websites before but I don’t know if they are using a separate javascript file or if it’s embedded in the form webpage. I never actually looked at the time.
Thanks for your help!
Rob