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 636937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:34:08+00:00 2026-05-13T20:34:08+00:00

I want to validate the fields of the list item while adding/editing and stop

  • 0

I want to validate the fields of the list item while adding/editing and stop the saving operation and provide the error information what the user made on that page itself.

For ex, if I want to prevent user not to leave few fields set before saving based on particular status of another field, I cannot make the field as mandatory.

  • 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-05-13T20:34:09+00:00Added an answer on May 13, 2026 at 8:34 pm

    Use PreSaveAction.

    Add a javascript function named PreSaveAction to your page (it’s best if you are creating a custom List Template and can modify the aspx page that will be used as EditForm and NewForm, otherwise try the Content Editor Web Part or by modifying the Master Page) and do all your custom validation from there.

    For example, I just used it on a project where we had three percent fields that had to equal 100%. I used the following javascript and it worked great:

    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;
    }
    
    function PreSaveAction() {
        var top = getTagFromIdentifierAndTitle("input", "TextField", "Top %");
        var middle = getTagFromIdentifierAndTitle("input", "TextField", "Middle %");
        var bottom = getTagFromIdentifierAndTitle("input", "TextField", "Bottom %");
        var valid = (100 == parseInt(top.value) + parseInt(middle.value) + parseInt(bottom.value));
        if (!valid) {
            alert("Top %, Middle %, and Bottom % must equal 100% when added.");
        }
        return valid;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built a registration form where I want to validate fields in it.
I want to validate required fields on diferent forms when i push on save
hibernate and i want to provide localized error messages for hibernate annotations so i
I have a form containing a list of input fields that the user populates
Basically I want to develop a BHO that validates certain fields on a form
I'm trying to validate some of the field in my form. and I want
I want to validate an XML file against an XML Schema file. It is
I want to validate a condition before doing the next step, but only raise
I want to validate below data using regex and python. Below is the dump
I want to validate a registration form that accepts an email address in the

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.