Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Validations in Custom List Form Fields in SPD

  Asked By: Steven    Date: Dec 22    Category: Sharepoint    Views: 10268

I have a custom list form in a custom aspx page, created through
SharePoint Designer. It has different form fields of different types like
Person or Group field, Multipicker Lookup field and so on. I need to provide
Required Field validations for these fields only in the page(*and not to the
underlying column*). I cannot put an <asp:RequiredFieldValidator> because I
need to assign a value to the ControlToValidate property which will be the
ID of the Control to be validated. But in case of Form Fields, the ID is of
the form ff1{$Pos} and hence I cannot assign this.



12 Answers Found

Answer #1    Answered By: Buddy Moon     Answered On: Dec 22

You can use the ASP.NET required field  validator control  for this. Simply
drag one RequiredFieldValidator control from the SPD toolbox for each field
to be validated. Then using the properties panel for each control you can
point one at each field to be validated. The ControlToValidate property
entry should be in the form  of 'ff#_#' for example ff3_1 for the third form
field in the web part. If you highlight the form field that you want to
validate you will see the form field ID in the properties of the field. I
do this all the time in SPD on custom  pages where I've added a DataForm Web

Why do you think you can't use the requiredFieldValidator control to
validate individual field controls.

Answer #2    Answered By: Vishala Verma     Answered On: Dec 22

Off the top of your head can this be used for conditional validation? I
have checkboxes on a NewForm.aspx (and EditForm.aspx) that, when checked, show
rows below the checkboxes and the rows become required. Only thing is that I
can't conditionally validate within SharePoint's controls. But, if I used the
RFV example you discuss then how would it be possible to conditionally validate
the fields?

Answer #3    Answered By: Rosalyn Craft     Answered On: Dec 22

I don't think you're going to be able to do that with these controls without
the use of code (scripting) which isn't supported in SPD.

Answer #4    Answered By: Bhavi Chauhan     Answered On: Dec 22

Are the other ASP.NET validator controls supported? Seems like you could
write some decent client validation with a CustomValidator -- and since
SharePoint isn't going anywhere without client scripting, you might be able
to make that fly.

Answer #5    Answered By: Carley Lott     Answered On: Dec 22

Because of its reliance on custom  server side code the Custom Validator is
the only Validator that won’t work in SPD as far as I know.

Answer #6    Answered By: Aastha Tatpatti     Answered On: Dec 22

Custom validator will work in SPD. I am using it. I was asking for

Answer #7    Answered By: Roop Kapoor     Answered On: Dec 22

I took another look, and if you use the CustomValidator the way it is
implemented in SPD then it will work. The problem is that the
CustomValidator in ASP.NET is normally used with both server side code and
has the option to add client side JavaScript. The Javascript will work, but
server side code can't be added in SPD. If you drag the CustomValidator
from the toolbox in SPD it masks the properties associated with server side
code. As long as you stick to javascript it will work.

As I pointed out the RequiredFieldValidator won't work with certain field
types like People/Groups and Lookup. You may be able to write some
Javascript for the CustomValidator that will work similarly.

Answer #8    Answered By: Kelley Obrien     Answered On: Dec 22

I don't deny your point. It does work. But for fields  of type Person
or Group or Lookup, if I follow your way, it says "An unexpected error has
occurred". Thats why I raised this question.

Answer #9    Answered By: Ashleigh Neal     Answered On: Dec 22

That explains the problem. The issue is not the ID of the control. It’s
that the built in ASP.net validators are all built around an expectation
that they are validating text. Person or Group fields  and Lookup fields
don’t result in text, so an error is generated when you try to use them with
these types  of fields. You would need to either write your own client side
Javascript or make the underlying field  required to make these fields
required. You can’t use the validator controls with these kinds of fields.
For what you want to do I think you will need your own custom  Javascript.

Answer #10    Answered By: Mitali Panchal     Answered On: Dec 22

Is this veracious? We can use RequiredFieldValidators with ListBox,
DropDownList and so on. I believe the validators are not expecting a text in
this case, if I am not wrong. Moreover, I could very well use
<asp:CustomValidator> (which is also an ASP.Net validator) with the Person
or Group field. Please try to understand that I am not trying to argue with
you, as you are a highly experienced and knowledgeable architect and I
am just a learning developer. I am trying to understand the concepts, thats

Answer #11    Answered By: Raghu Gouda     Answered On: Aug 22

Im following buddy moon approach. But whenever I refer controltovalidate in custom newform.aspx as "ffn_1" (where n is the number of form field) it is throwing me error. Please help

Didn't find what you were looking for? Find more on Validations in Custom List Form Fields in SPD Or get search suggestion and latest updates.