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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:06:21+00:00 2026-05-24T04:06:21+00:00

I am creating a JQuery dialog where I have use data from a Model

  • 0

I am creating a JQuery dialog where I have use data from a Model I want to validate, but the box is just closed, if I then click to open the dialog again I can see the red text indication errors, but it just closed.

function createEditorDialog() {
    $('#floatsam_editor').dialog({ bgiframe: true, autoOpen: false, modal: true, width: 512,
        buttons: {
            'Close': function () { $('#floatsam_editor').dialog('close'); },
            'Create': function () {
                $('#flotsam_form').submit();
                $('#floatsam_editor').dialog('close');
            }
        }
    });
};

So the red text comes at the submit, but is closed right after, even though the validation failed.

Here is part of the ajax beginform that is shown

<div id="floatsam_editor">
@using (Ajax.BeginForm("CreateFlotsam" , "Flotsam", new { }, new AjaxOptions { HttpMethod = "Post", OnSuccess = "systematic_flotsam.successRequest" }, new { Id = "flotsam_form" }))
{
    <div>
        <fieldset>
            <legend>Create Log Entries</legend>
            <div >
                <span class="editor-label">
                        @Html.LabelFor(m => m.Received.Date)
                    </span>
                    <span class="editor-field">
                        @Html.TextBoxFor(m => m.Received.Date, new { id = "flotsam_date", @class="datepicker", maxlength="10"})
                    </span>
                    <span class="editor-field">
                        @Html.TextBoxFor(m => m.Received.Hour, new { id = "flotsam_hours", maxlength="2" })
                    </span>:<span class="editor-field">
                        @Html.TextBoxFor(m => m.Received.Minute, new { id = "flotsam_minutes", maxlength="2"})
                    </span>
                    <span>
                        @Html.ValidationMessageFor(m => m.Received.Date)
                        @Html.ValidationMessageFor(m => m.Received.Hour)
                        @Html.ValidationMessageFor(m => m.Received.Minute)
                    </span>
                </div>

            <div>
                <div class="editor-label">
                    @Html.LabelFor(m =>m.Flotsam.Informant)
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(m => m.Flotsam.Informant, new { @class = "flotsam_dialog_editor_field" })
                    @Html.ValidationMessageFor(m =>m.Flotsam.Informant)
                </div>
            </div>

Part of my model is here

        [DisplayName("Informant:")]
    [Required]
    public object Informant { get; set; }

    [DisplayName("Flotsam Nature:")]
    [Required]
    public object FlotsamNature { get; set; }

    [DisplayName("Position of Loss:")]
    [Required]
    public object Position { get; set; }

And as seen it has 3 propertys which are required, but again it still closes if I dont enter anything in my ajax form

So how do I make the dialog box not close when model validation fails?

A very important note is that all this is done on one site and on client side, I do not want to reload the page.

  • 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-24T04:06:22+00:00Added an answer on May 24, 2026 at 4:06 am

    Only close the dialog if the form is valid.

    if($("#flotsam_form").valid())
    {
       $('#flotsam_form').submit();
       $('#floatsam_editor').dialog('close');
    }
    

    This way it dialog will stay open and validation errors will appear

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.