views:

46

answers:

1

I have managed to implement the validator on a form, and is working fine for all my needs apart from a crucial last one.

Does anyone know how I would go about (or whether it's even possible) to extend or create a validation message that is purely a warning but still allows the form to be submitted (i.e. the field is still valid).

To illustrate this; I have an field that is required, number, and within a range (0 - 99999), but I want to show a warning (as per the error messages) if say type in over 5000 saying that this value is high for their circumstances, consider changing it.

Hope that makes sense!


EDIT: Sorry should have mentioned that I would like the message to appear as all the other validation error messages at the side of the element when they leave focus. I didn't know whether it was possible to still have a rule that fires after all the others are valid but at the same time mark the field as valid or something?

+1  A: 

You can use the submitHandler from the validate options:

$(".selector").validate({
   submitHandler: function(form) {
    if (value > BIG_VALUE) {
        if (confirm("...")) {
           form.submit();
        }
    }
    else {
      form.submit();
    }
   }
})
kgiannakakis
Thanks. Sorry should have mentioned that I would like the message to appear as all the other validation error messages at the side of the element when they leave focus. I didn't know whether it was possible to still have a rule that fires after all the others are valid but at the same time mark the field as valid or something?
Monkeeman69