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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:21:53+00:00 2026-06-04T01:21:53+00:00

I have a textbox and im trying to check if it has anything in,

  • 0

I have a textbox and im trying to check if it has anything in, and if it doesnt i need to show a relevant error message but even when i have entered something in it, it continues to show the error message

Iv created a it here http://jsfiddle.net/Atkinson1988/SzuVQ/

var DiarisedReason = $("#txtDiarisedReason").val();
if (jQuery.trim(DiarisedReason).length < 0);
{
alert('Please Enter Diarised Notes');
return false;
}
​

Im not sure what im doing wrong?

Thank you for your time.

  • 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-04T01:21:54+00:00Added an answer on June 4, 2026 at 1:21 am

    I suggest you to use RequiredFieldValidator in asp.net, as it provides easy way to validate the server side controls.

    <asp:TextBox id="TextBox1" runat="server"/>
    

    and for Required field validator

    <asp:RequiredFieldValidator id="RequiredFieldValidator2"
                        ControlToValidate="TextBox1"
                        Display="Static"
                        ErrorMessage="*"
                        runat="server"/> 
    

    then check for Page.IsValid in the page load event to submit the form.

    if(page.IsValid)
    {
      //then do success
    }
    else
    {
     //do failure
    }
    

    if you want javascript/jquery solution, then you can try like this

    you can do with val() also. something like this . ! will check for the value in the textbox value.

    if(!$("#txtDiarisedReason").val())
     alert('you have to enter the Reason');
    

    alternativiley, you can check for trimmed value also. by using trim()

    check demo : JsFiddle

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

Sidebar

Related Questions

I have an arraylist of asp.net controls (textbox, etc). I need to check if
I am trying to have a textBox auto complete with values from a database.
I have my own textbox which inherits System.Windows.Forms.TextBox I am trying to display texts
I'm trying to use a RegularExpressionValidator to validate a TextBox input length. I have
I have: Textbox(Multi-line) Panel Different controls inside panel (buttons,textbox) Scenario: I need to add
I am trying to validate textbox values during runtime in vb.net I have following
I am trying to Implement an New AutoComplete Control . I have an textbox
I am getting this error message: --------------------------- You have an error in your SQL
I know this has been asked before but I have looked at every answer
I've got a standard TextBox control which I'm trying to have mimic the soft

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.