These forums are locked and archived, but all topics have been migrated to the new forum. You can search for this topic on the new forum: Search for form validation with onsubmit and js on the new forum.
Hello,
I'm trying to integrate a javascript file with a validation function with the ui-lib functions that generate forms. To do so i create my interface as follows:
[snip] use WebminCore; my $js = "<script type='text/javascript' src='/virtualmin-myextension/validate.js' ></script>\n"; print header("Mailboxes Configuration", null, undef, undef,0,0,undef, $js); [snip] print ui_form_start("","post",undef, "onSubmit=\"return check_form_valid()\");
the mailbox.js content is:
function check_form_valid() { alert("hello"); return false; }
the produced HTML code is like this:
<head> [snip] <script type='text/javascript' src='/virtualmin-myextension/validate.js' ></script> [snip] </head> <body ...> [snip] <form class='ui_form' action='' method=post onSubmit="return check_form_valid()">
apparently the form validation does not happen (no alert is executed). on the contrary, if I build the form as: print ui_form_start("","post",undef, "onSubmit=\"return alert('something')\");
i can see the alert popup.
the js path seems to be correct, because in firefox i can see the source file and double click in the "src" link of the element "<script src="/virtualmin-myextension/validate.js' >" and it loads the correct file.
is it possible I'm missing something?
thanks in advance