Required Sharepoint fields - alert on save


Posted by Katy - Dec 2 ’15 at 04:21

I have a form based on a very big list which has a lot of required/mandatory fields and i need an alert going on Save if any of that fields were not filled out. I found the solution here how to do it, but it means to include all the names of the required Sharepoint fields which is quite a pain. Is there a way to pop out an alert if any of the required fields are empty?

  • rostislav
    Member for: 8 years 4 months 21 days
    #1 by rostislav Dec 3 ’15 at 05:41

    You didn't say how you are doing your validation, so I'll tell you of two ways of doing it:


    1. You can make a field mandatory in the column settings and specify validation rule in the list settings: List settings -> Validation settings

    2. You can do it with a JavaScript script, it would look something like this:

    	//here you'll need to include all required fields. bare in mind you'll have to accomodate for different field types, as fields of different types may return different values when they are empty, e.g. a people picker field will return an array, so you'll have to check it's length: fd.field('person').value().length
    	if (!(fd.field('field1').value() && fd.field('field2').value()))
    		alert('some required field hasn't been filled in');
    		return false;
    	return true;

    I don't think you can make it much more succinct than that.

  • Katy
    Member for: 9 years 2 months 10 days
    #2 by Katy Dec 3 ’15 at 09:47

    [#1]: Thanks Rostislav, I've seen the second solution before, I just thought there is a way to make a condition looks like "if the item is not saved then the alert goes out", but I guess I would have to do insert all the fields

Displaying 1 to 2 of 2 messages