1

I am stuck on one condition where in I am trying to check if drop down value = select a value then show alert and then again if it is yes it makes two more columns visible. But there is a condition where in if a text field contains Executive as text which will be automatically retrieved from another list it hides few columns. I am running validation on presave function but if the fields are hidden in the form it still gives me an alert for the value. I want to know as to how can i ignore the validation of the hidden fields?

my code when the fields are visible

Frequencydeliverables = $("select[title='Frequency of the Deliverables'] option:selected").text();

if(Frequencydeliverables=="Select a Value")
{
alert("Please select an appropriate value");
$("select[title='Frequency of the Deliverables']").focus();
return false;
}
0

As you are using the preSaveAction() function in SharePoint, You will need to make the fields that could be possible hidden to non-required as default and then do your own validation against all the fields that needs to be filled out/validated by adding your own logic to fire when trying to save the list form.

Just as you validate the field in your code, you have to do the same thing for all the columns necessary, and they can't be required by default as that trigger the SharePoint function PreSaveItem() that is called when you click on the OOTB Save button and validates all the required fields (that are required from the column settings).

As you need different type of information based on the choices/values selected while filling out the form.

function PreSaveAction() {
    Frequencydeliverables = $("select[title='Frequency of the Deliverables'] option:selected").text();

    if(Frequencydeliverables == "Select a Value")
    {
        alert("Please select an appropriate value");
        $("select[title='Frequency of the Deliverables']").focus();
        return false;
    }
    else {
        return true;
    }
};
  • is it possible you could help me out with this. i would probably need one example to get me going. – jayant khushalani Apr 13 '18 at 4:55
  • none of the fields in my form are required. i am applying custom validation on the form. i am aware of how to perform simple blank validation but i am not aware as to how to remove validation for fields which are hidden in a form. Say there is a text field which contains Executive or dynamic only then value A,B and C will be visible and i have to perform validation on it but when the text field does not contain Executive or dynamic it still tries to validate value A,B and c. How can i remove that? – jayant khushalani Apr 13 '18 at 5:43
  • It would be easier if you add all of your custom jQuery to the question. – Christoffer Apr 13 '18 at 6:29
  • i cannot put the whole code as it is exceeds the character limit. i would put a snippet for now. if(Frequencydeliverables=="Select a Value") { alert("Please select an appropriate value"); $("select[title='Frequency of the Deliverables']").focus(); return false; } I want to remove validation for this field if it is hidden in the form. – jayant khushalani Apr 13 '18 at 6:31

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.