SharePoint Custom List Form doesn't validate required fields

4k views Asked by At

My Story:

I had to customize the page NewForm.aspx, so I hidden the default ListFormWebPart and added a Custom List Form [DataFormWebPart] using SharePoint Designer.

My problem:

If required fields are empty, SharePoint now triggers a beautiful Error page instead of putting the usual validation message below each empty fields.

Do you have any idea how I can reactivate the empty required field validation?

Thank you!

1

There are 1 answers

1
djeeg On

Sounds like the client side validation routine is not getting called.

The ListFormWebPart does this in OnLoad();

this.Page.Form.Attributes["onsubmit"] = "if (typeof(_spFormOnSubmitWrapper) == \"function\") return _spFormOnSubmitWrapper();";

Which looks to inject the client side validation call.

The DataFormWebPart web part only seems to inject it when async is turned on.

You might have to add it in manually.