Having just upgraded to 3.06 from v1 it's a lot better now that we have more control over the markup! The problem I am left with currently, and I may just be having a challenging day, is how to prevent validation on page load? We don't want all of the validation message displayed on page load only when the form is either submitted or you move between fields?
I don't want to remove the validation code, I still want form validation just not on page load. The new version of contour declares the use of jquery.validate in the Form.cshtml file as follows:
If you don't want to have the form validation on page load than when do you want it? Maybe add an if statement around these 2 Html helpers so it will only be called when you want to?
@Tim, yes it does. All required field even in preview mode say "Field Name is a required field" beside them.
@Jeroen, as with most forms the client would like validation to occur either when the form is submitted or your navigate from one field to another e.g. onblur.
Interesting, since you asked me to do that it's obvious that the messages displayed do not reflect the "required error message" format defined in the settings?
Prevent Validation on page load
Having just upgraded to 3.06 from v1 it's a lot better now that we have more control over the markup! The problem I am left with currently, and I may just be having a challenging day, is how to prevent validation on page load? We don't want all of the validation message displayed on page load only when the form is either submitted or you move between fields?
Am I missing something obvious?
Thanks, Simon
If you're having a Razor file which renders the form you can probably remove the validation code from there.
Jeroen
I don't want to remove the validation code, I still want form validation just not on page load. The new version of contour declares the use of jquery.validate in the Form.cshtml file as follows:
however I can't see where the call to validate on page load is coming from or how to prevent it.
If you don't want to have the form validation on page load than when do you want it? Maybe add an if statement around these 2 Html helpers so it will only be called when you want to?
Jeroen
Comment author was deleted
Hmm validation shouldn't happen on page load, @Simon does this also happen when you preview the form in the Contour section?
@Tim, yes it does. All required field even in preview mode say "Field Name is a required field" beside them.
@Jeroen, as with most forms the client would like validation to occur either when the form is submitted or your navigate from one field to another e.g. onblur.
Thanks, Simon
Comment author was deleted
@Simon could you post a screenshot of the form settings tab?
Comment author was deleted
Well is there something setup in the indicator part? That will always show
Interesting, since you asked me to do that it's obvious that the messages displayed do not reflect the "required error message" format defined in the settings?
Comment author was deleted
Looks like you might have gotten the jquery validate defaults, care to share the umbraco/contour versions? then I'll see if I can reproduce
Comment author was deleted
Tried with the same settings but don't see it, still only triggers on submit... did you customize the views?
Sure, Umbraco 4.11.1 and Contour 1.1.10 with the 3.0.6 upgrade.
Comment author was deleted
Ok thanks will see if I can reproduce
btw do you get any js errors?
Comment author was deleted
Just tried (with upgrade from 1.1.10 to 3.0.6) and I don't get the issue
Any chance I can take a look at the installation that has the issue, you can mail details to tg at umbraco dot com
Thanks,
Tim
Sure, I will send over details now.
Comment author was deleted
Ok issue is because the form view was modified, the part that is outputting the validation message was changed
from
@if (Model.ShowFieldValidaton)
{
@Html.ValidationMessage(f.Id)
}
to
@if (Model.ShowFieldValidaton)
{
if (!string.IsNullOrEmpty(f.RequiredErrorMessage))
{
@Html.ValidationMessage(f.Id, f.RequiredErrorMessage)
}
else
{
@Html.ValidationMessage(f.Id, string.Empty)
}
}
and it appears that that is causing the message to be displayed on load
This has been done (and already tried) and does not seem to correct the issue.
Comment author was deleted
Just tested on local install and that did the trick , mailed you the updated view :)
is working on a reply...