// add form with markup id setter so it can be updated via ajax
Form form = new Form("form", new CompoundPropertyModel(bean));
add(form);
form.setOutputMarkupId(true);
FormComponent fc;
// add form components to the form as usual
fc = new RequiredTextField("name");
fc.add(StringValidator.minimumLength(4));
fc.setLabel(new ResourceModel("label.name"));
form.add(fc);
form.add(new SimpleFormComponentLabel("name-label", fc));
fc = new RequiredTextField("email");
fc.add(EmailAddressValidator.getInstance());
fc.setLabel(new ResourceModel("label.email"));
form.add(fc);
form.add(new SimpleFormComponentLabel("email-label", fc));
// attach an ajax validation behavior to all form component's onkeydown