Hi,
On 2007.05.31, at 11:30, Viktor Matić wrote:
Hi,
I have problem with js validator, which looks like:
Tapestry.validate_basket_qty = function(event, fieldId, min, message)
{
var o = this.find(fieldId);
var value = o.value;
if (value == "") return;
if (Number(value) < min && Number(value) != 0 )
event.invalid_field(field, message)
}
it seems that default_invalid_field_handler is not registered in
FormEventManager for forms with custom validator.
I could not find why. So I took ugly shortcut and resolved this issue
by doing same thing which should be done in
default_invalid_field_handler.
Now js validator looks like this:
Tapestry.validate_basket_qty = function(event, fieldId, min, message)
{
var o = this.find(fieldId);
var value = o.value;
if (value == "") return;
if (Number(value) < min && Number(value) != 0 )
{
Tapestry.set_focus(o);
window.alert(message);
event.abort = true;
event.cancel_handlers = true;
}
}
as it can be seen it is similar to Tapestry min validator with
minor change (it accepts 0). Script
is placed in our package and it is used by custom validator render
method which extends BaseValidator.
Page renders correctly and above function is called on form submit,
but for some reason
event.invalid_field(field, message)
fails to do the job. Page submits which should not happen. After it
is submitted server side validation
fires.
Regards,
Viktor Matic
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]