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

  • SEARCH
  • Home
  • 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 9126489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:03:20+00:00 2026-06-17T07:03:20+00:00

I am working on ASP.Net MVC 2 application. I need to validate below mentioned

  • 0

I am working on ASP.Net MVC 2 application. I need to validate below mentioned pop up by using jQuery because I am sending that data using an AJAX call as below.

Note : I am not using any form element for my UI

addButton.off('click').on('click', function () {
    $.ajax({
        type: "POST",
        url: "/incentives/CreditPackagesAdd",
        data: dataPost,
        dataType: "json",
        success: function (url) {
        }
    });
});

My Pop up window is as below:

enter image description here

My UI Html code is as below :

<div class="dialog form simpleForm slimForm" id="add-package" data-width="350" data-title="Add Credit Package">

            <ul>
                <li>
                    <label for="name">
                        Name</label>
                    <input type="text" name="name" id="name" />
                </li>
                <li>
                    <label for="value">
                        Value</label>
                    <input type="number" name="value" id="value" /></li>
                <li>
                    <label for="purchasePrice">
                        Purchase Price</label>
                    <input type="number" name="purchasePrice" id="purchasePrice" /></li>
                <li>
                    <label for="expirationPeriod">
                        Good for</label>
                    <%: Html.PopUp<ExpirationPeriod>("expirationPeriod") %></li>
                <li>
                    <label for="valid">
                        Start Date</label>
                    <input type="date" class="datePicker" name="valid" id="valid" value="<%: DateTime.Today.ToString("M/d/yyyy") %>"
                        data-min="<%: DateTime.Today.ToString("M/d/yyyy") %>" /></li>
                <li>
                    <label for="expiration">
                        Expiration</label>
                    <input type="date" class="datePicker" name="expiration" id="expiration" data-min="<%: DateTime.Today.ToString("M/d/yyyy") %>" /></li>
                <li>
                    <label for="purchasedByCustomer">
                        Cannot be Purchased By Customer</label>
                    <%:Html.CheckBox("isPurchasedByCustomer")%>
                </li>
                <li class="buttons">
                    <button type="button" id="addButton" class="actionButton default">
                        Add</button></li>
            </ul>

        </div>

My questions are:

  1. I know I am unable to validate my inputs by using DataAnotations. So how can I do that by using Jquery?

  2. Or Any jquery library for this kind of validation ?

  3. Or Suggest any other method?

Thanks 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-17T07:03:21+00:00Added an answer on June 17, 2026 at 7:03 am

    Use this function to check the various text boxes…

    function validateData() {
        // Name
        var n  = $("#name").value;
        if (n == null || n == "") {
            alert("Please fill out name.");
            return false;
        }
    
        isprice = /^\d+\.\d{2}$/;
    
        // Value
        var val  = $("#value").value;
    
        if (val == null || val == "") {
            alert("Please fill out name.");
            return false;
        } else if(!isprice.test( val )) {
            alert("Please enter valid data for Value.");
            return false;
        }   
    
        // Purchase Price
        var price  = $("#purchasePrice").value;
    
        if (price == null || price == "") {
            alert("Please fill out name.");
            return false;
        } else if(!isprice.test( price )) {
            alert("Please enter valid data for Purchase Price.");
            return false;
        }
    
        return true;
    }
    

    Then modify your AJAX call like this:

    addButton.off('click').on('click', function () {
        if(validateData()) {
            $.ajax({
                type: "POST",
                url: "/incentives/CreditPackagesAdd",
                data: dataPost,
                dataType: "json",
                success: function (url) {
                }
            });
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an ASP.NET MVC application and using jQuery. I understand from
I am working on a Facebook tab application. I am using asp.net MVC 2
I'm working on multilingual Asp.NET MVC application. In url i need to use category
I'm working on an ASP.NET MVC web application that will be deployed across multiple
I am working on an ASP.Net Mvc 3 application using FormsAuthentication with a custom
I have an ASP.NET MVC application that I'm working on. I've been developing it
I am working on an ASP.NET MVC application using SQL Dapper for retrieval and
I've been working on my first major ASP.NET MVC application (plus lots of jQuery)
I have an existing ASP.NET MVC application that is working well. It provides a
Currently working on an ASP.NET MVC 3.0 application and using FormsAuthentication . When 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.