loop all fields in fd
- Jens.Hetze
- Posts: 22
- Joined: Sat May 20, 2017
Hi SP Forms Designer team,
is there a possibility to loop all fields in fd object? I want to check all asterisks to implement a simple required validation.
Or is there a better possibility to do this?
Thanks in advance.
Jens
is there a possibility to loop all fields in fd object? I want to check all asterisks to implement a simple required validation.
Or is there a better possibility to do this?
Thanks in advance.
Jens
Hello Jens.Hetze,
If the filed is required it will be validated by default.
If you need custom validation you can add it to your form with the help of Forms Designer's JS-framework and check whether all the required fields are filled in. Here is a sample:
Please also have a look at the 'How to conditionally hide, disable, and make mandatory fields on SharePoint forms dynamically' article, 'Require field based on condition' part for more information.
If the filed is required it will be validated by default.
If you need custom validation you can add it to your form with the help of Forms Designer's JS-framework and check whether all the required fields are filled in. Here is a sample:
Code: Select all
fd.onsubmit(function() {
if (!fd.field('Field1').value()) {
alert('Please, fill-in the Field 1');
return false;
}
return true;
});
- Jens.Hetze
- Posts: 22
- Joined: Sat May 20, 2017
Hi mnikitina.
Thank you for your answer. Maybe it was too little information. I know that if the fields in SharePoint are marked as required, validation will be performed by default. In my case, however, all SharePoint columns are optional because they should be filled out in several workflow steps. For this reason, I would like to retrieve all fields marked with an asterisk in SP Forms Designer and implement my own validation.
I hope that helps to understand my case.
Thank you for your answer. Maybe it was too little information. I know that if the fields in SharePoint are marked as required, validation will be performed by default. In my case, however, all SharePoint columns are optional because they should be filled out in several workflow steps. For this reason, I would like to retrieve all fields marked with an asterisk in SP Forms Designer and implement my own validation.
I hope that helps to understand my case.
Jens.Hetze,
You can add the Asterisk to the Field Name in the field settings. And you can add custom validation using the script. This should be done for each field separately
or you can use one validator for all fields.
Anyway you need to specify each field that you want to validate.
You can add the Asterisk to the Field Name in the field settings. And you can add custom validation using the script. This should be done for each field separately
Code: Select all
fd.onsubmit(function() {
if (!fd.field('Field2').value()) {
alert('Please, fill-in the Field 2');
return false;
}
return true;
});
fd.onsubmit(function() {
if (!fd.field('Field2').value()) {
alert('Please, fill-in the Field 2');
return false;
}
return true;
});
Code: Select all
fd.onsubmit(function() {
if (!fd.field('Field1').value() || !fd.field('Field2').value() || !fd.field('Field3').value()) {
alert('Please, fill-in required fields');
return false;
}
return true;
});
Anyway you need to specify each field that you want to validate.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 9 guests