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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:27:09+00:00 2026-05-26T23:27:09+00:00

these are my models. public class Question { private string _questionNo; private string _questionText;

  • 0

these are my models.

public class Question
{

private string _questionNo;  
private string _questionText; 
private List<Option> _options;

public List<Option> Options
{
    get { return _options; }
    set { _options = value; }
}
public string QuestionNo
{
    get { return _questionNo; }
    set { _questionNo = value; }
} 
public string QuestionText
{
    get { return _questionText; }
    set { _questionText = value; }
} 

}

public class Option
{

private string _optionText; 
private string _optionNumber; 
public string OptionText
{
    get { return _optionText; }
    set { _optionText = value; }
}
public string OptionNumber
{
    get { return _optionNumber; }
    set { _optionNumber = value; }
} 
}

these is my controller

   public ActionResult GetQuestion(int id,string gid)
    { 
        var vewmodel = ques.GetQuestion(Gid, Uid, id);
        return View(vewmodel);
    }

this is my view.

     @model mobilesurveys.mt.Models.Question  
     @{ ViewBag.Title = "Question"; }
    <div data-role="header" data-theme="b">
     <h1>
    @Model.SurveyName</h1>
    </div>
   @if (@Model.QuestionType == 7)
   {   
<div data-role="fieldcontain">
    @using (Html.BeginForm("SaveDropDown", "GetQuestion", Model))
    {
        @Html.AntiForgeryToken()

        <fieldset>
            <label class="select">@Model.QuestionText
            </label>
            <br />
            <select name="selectedObjects" id="selectchoice1" data-native-menu="false">
                <option value="--select--">--Select--</option> 
                @foreach (var item in Model.Options)
                {

                    if (@item.IsAnswer == true)
                    {
                    <option selected="selected"  value="@item.OptionNumber">@item.OptionText</option>
                    }
                    else
                    {
                    <option  value="@item.OptionNumber">@item.OptionText</option>
                    }

                }
            </select>
        </fieldset>
        <p>
            <input type="submit" value="Next" />
        </p>
    }
    </div>
   }

so i am binding the optoins based on QuestionTypeId(RadioButtions,CheckBoxes,TextBox,Select). Now I want to validate the data at clientside. I am using Jquery Scripts.

How can i write the validations. any help is appreciated.

Thanks.

  • 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-26T23:27:09+00:00Added an answer on May 26, 2026 at 11:27 pm

    There are two methods.
    1.You can do this by adding annotation in the model class
    add like this line in model

    [Required(ErrorMessage = "Title is required"), StringLength(230)]
    

    in this way add annotation above the variable where you want.

    Or
    2.You can use jquery code to validate.
    I am giving you the code

    $(document).ready(function () {
            $("#SubmitForm").click(function (e) {
                var textContent = $("#TextContent").val();
                textContent = jQuery.trim(textContent);
                if (textContent == "") {
                    alert("Content field cannot be empty.");
                    $("#TextContent").focus();
                    return false;
                }
    
    
            });
        });
    

    In this way you can check field in jquery .
    Reply me if you find any prob

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

Sidebar

Related Questions

excuse me for my ugly english) ! Imagine these very simple models : class
I have the following model: public class Product { public int Id { get;
I have a model like this defined... public class Product{ private long timestamp; //
I have another question that's connected with my class: public class Parent { public
I have the following abstract class: public abstract class TemplateBase { public abstract string
The situation is as follows: I've got 2 models: 'Action' and 'User'. These models
In my models.py, I user these code to extent two fields: User.add_to_class('bio', models.TextField(blank=True)) User.add_to_class('about',
I'm kind of torn between these two error-handling models: Create a boolean Error and
I have some models; Vocabularies (tags lists), Labels (tags) and different articles types. These
I have the following java model class in App Engine: public class Xyz ...

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.