Required Sharepoint fields - alert on save
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?
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:
I don't think you can make it much more succinct than that.
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:
Code: Select all
fd.onsubmit(function(){
//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;
});
-
- Information
-
Who is online
Users browsing this forum: No registered users and 6 guests