1. I have a form which is validating quite nicely, using the
validation plugin.
On the form, a user enters a postcode, a googlemap pops up, user drags
the marker and saves it and the lat/lng of the marker is copied back
to hidden input fields in the parent form.

I want the form to validate that those hidden input types are not
empty - as an empty field indicates the lat/long had not been saved.

I can get it to validate - but I can not get the custom error message
to show as it is looking (i think) for an input field. I have tried to
get it to be placed in a blank div above. Nope. InsertAfter overwrites
the message already there.

How do I get the error message for input type="hidden" as the field
lng and lat are - to show somewhere?

 , errorPlacement: function(error, element) {
           if (element.attr("name") == "lat" || element.attr("name")
== "lng" ) {
             error.append("#some-div-to-put-this-msg");
           } else {
             error.insertAfter(element);
          }
         }



2. then - as they are hidden fileds, I don't want the invalidHandler
message to include them in its count - how do I do that?

 invalidHandler: function(form, validator) {
        // show error message help at top of form
          var errors = validator.numberOfInvalids();

-- someway say that if the error comes from input type=hidden - don't
count it here

          if (errors) {
            var message = errors == 1
              ? 'You missed 1 field. It has been highlighted below.
Please complete it as indicated.'
              : 'You missed ' + errors + ' fields. They have been
highlighted below. Please complete them as indicated.';
            //  alert(message);
            $("div.form-errors").html(message);
            $("div#form_help").hide();
            $("div.form-errors").show();
          } else {
            $("div.form-errors").hide();
          }
        }



thanks

Reply via email to