Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8083403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:27:40+00:00 2026-06-05T17:27:40+00:00

I am using SharePoint 2010 and have a customized newform.aspx and editform.aspx that I

  • 0

I am using SharePoint 2010 and have a customized newform.aspx and editform.aspx that I am using JQuery to create several tabs due to the amount of fields and length of the forms.

One of the issues that I am having is how to visually advise the user when they are attempting to save the form but have not entered values in some (or all of the required fields). I am using the OOTB validation features in SharePoint to indicate which fields need to addressed, however since many of the required fields are now on different tabs I would like to pop-up an alert window indicating which required fields need to be addressed prior to saving the form.

Normally I would only be dealing with two or three required fields, but in this case I am dealing with eight required fields and possibly more. In the past I would do the following using JavaScript if else statements:

 function PreSaveAction() {
    var tbTitle = getTagFromIdentifierAndTitle("input", "TextField", "Title");
    var tbVisitor = getTagFromIdentifierAndTitle("input", "TextField", "Visitor"); {
        if (tbTitle.value == "" && tbVisitor.value == "") {
            alert(tbTitle.title + ' is a required field' + '\n' + tbVisitor.title + ' is a required field');
            return true;
        } else {
            if (tbTitle.value == "") {
                alert(tbTitle.title + ' is a required field');
                return true;
            } else {
                if (tbVisitor.value == "") {
                    alert(tbVisitor.title + ' is a required field');
                    return true;
                } else {
                    return true;
                }
            }
        }
    }
}
function getTagFromIdentifierAndTitle(tagName, identifier, title) {
    var len = identifier.length;
    var tags = document.getElementsByTagName(tagName);
    for (var i = 0; i < tags.length; i++) {
        var tempString = tags[i].id;
        if (tags[i].title == title && (identifier == "" || tempString.indexOf(identifier) == tempString.length - len)) {
            return tags[i];
        }
    }
    return null;
}

Due to the fact that I have so many required fields to address I know that multiple nested if else statements is not the most efficient way to accomplish. Would utilizing switch case be the way to go? Possibly looping? How would I go about doing this (I am not overly proficient with JavaScript)?

Thanks for the help in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:27:41+00:00Added an answer on June 5, 2026 at 5:27 pm

    You don’t need nested statements. Just go through your fields one at a time to build your alert, then trigger it:

    var alertString="";
    
    if (tbTitle.value == "") {  
        alertString+= tbTitle.title + ' is a required field' + '\n';  
    }
    if (tbVisitor.value == "") {  
        alertString+= tbVisitor.title + ' is a required field' + '\n';  
    }
    ...
    // After going through all fields:
    if (alertString) {alert(alertString);}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using SharePoint 2010 Foundation. We have an item in a list that
I have to create a SharePoint 2010 ribbon element (tabs, buttons, groups, etc.). Is
My problem is this one, I am using Sharepoint 2010, I have a form
I'm using SharePoint 2010. I want to create new view for my list. The
We are planning to create two sharepoint web applications using SharePoint 2010 Enterprise Edition.
In SharePoint 2010 I have a visual web part that uses SP.UI.ModalDialog.showModalDialog The dialog
We are currently using TFS 2010 and have a Team site of SharePoint 2007.
I am using SharePoint 2010 and I have developed a SharePoint 2010 solution which
I have developed a sharepoint 2010 visual webpart application with multiple visual webparts using
SharePoint 2010 I have an enterprise wiki site, that I exported and imported from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.