2

Is there a function that can be called in presaveaction that will do the preliminary SP required fields validation first?

For a simple example: A form has a start date and an end date, both required fields.

Before I do my presaveaction test that Start date < end date, I'd like to ensure that the fields have already been filled in as part of the standard SP required field validation testing.

3
  • Do you mean solution should validate the condition on change of end date like a client side validation? May 23, 2017 at 1:40
  • No. I mean that I want all the inbuilt standard required field validation to be done before starting the presaveaction. Not related to any change event.
    – southskies
    May 23, 2017 at 3:07
  • Did you ever find a solution for run the build in validation prior to en presave action?
    – Morten K
    Nov 1, 2018 at 10:52

2 Answers 2

0

The only solution I can think of is to write a script to look through the page to find all the fields that have the words "Required Field" in the title and see if there is any value assigned to it.

I don't think I have any inclination to do this. Perhaps an addition to jQuery one day?

Anyone keen enough could start with something like this:

https://www.mavention.nl/showing-required-fields-when-editing-a-page-sharepoint-2013/

The answer to How do I trigger the default form validation without submitting the form was that it could not be done.

Whilst not an ideal solution, future readers could look up Save conflict - reset ratings and ratingscount in presaveaction ... the use of window.onbeforeunload may give inspiration.

-1

You can use PreSaveAction like the following:

<script language="javascript">
function PreSaveAction()
{
    //get your start and end date value
    //perform validation such as end date could not before start date
    return true;  // OK to proceed with the save item 
}
</script>

other useful URL: http://chandanbadajena.blogspot.com.au/2011/09/add-javascript-date-validation-into.html

here also some other answer How do I trigger the default form validation without submitting the form

1
  • No, these aren't solving the problem. THE REQUIREMENT IS: I do not want to have to validate that all the required fields have been supplied within the presaveaction. I want this inbuilt function to be done before presaveaction is called (or as a standard function that can be included at the start of the presaveaction function).
    – southskies
    May 23, 2017 at 3:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.