On 30 oct, 18:17, danblack <[email protected]> wrote:
> I have a html-form
>
> <form id="my_form">
> <input type="text">
> <input type="submit" id="submitBtn" />
> </form>
>
> and I want to set a custom handler on a form submit event in my GWT
> application.
>
> I tried to use
> 1) formPanel.addSubmitHandler(submitHandler);
> 2) formPanel.addSubmitCompleteHandler(submitCompleteHandler);
> but coudn't catch this event
>
> I also tried to cast an input element to the Button element, but
> failed.
> el = DOM.getElementById("submitBtn");
> InputElement in = InputElement.as(el); // exception throws here
>
> Do you have any ideas how to set a custom submit event handler.
I'm currently using this without any problem:
FormPanel form = FormPanel.wrap(Document.get().getElementById
("loginForm"));
form.addSubmitHandler(new FormPanel.SubmitHandler() {
public void onSubmit(FormPanel.SubmitEvent event) {
if (!validateForm()) {
event.cancel();
}
}
});
where validateForm() uses other Document.get().getElementById(...) to
check that the username and password fields are both filled.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---