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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:26:08+00:00 2026-05-24T17:26:08+00:00

If the user did not give any value to text box the value 0

  • 0

If the user did not give any value to text box the value 0 (zero) to be set on blur but the text box should not display the value How can i do it using jquery

<g:textField name="distance" id = "distance" value="${tripInstance?distance}" min="0" class="number" />
  • 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-24T17:26:09+00:00Added an answer on May 24, 2026 at 5:26 pm

    You can’t as “value” is the display value.

    Only way you be able to do it is intercept the form submission and prepopulate with default values if none are entered.

    Failing that, the best place to hand it would be at the server end, ultimately where this kind of thing should happen.

    That said, you should never rely on JavaScript to set/enforce default values as the user may not have JavaScript enabled or worse they are manipulating before sending it to you.

    In that respect JavaScript should be considered dirty.

    On second thoughts, you could do this:

    <input type="hidden" name="distance" id = "disatance_default" value="0" />
    <g:textField name="distance" id = "distance" value="${tripInstance?distance}" min="0" class="number" />
    

    I think, if nothing was entered into the “textField” it wouldn’t get sent back to the server, and therefore the hidden input field with the same name would take precedence.

    The last most field of that name (which contains a value) will always be the one that is sent back to the server.

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

Sidebar

Related Questions

The story: I had class User and class Organization: User. I did not use
I want to have a UISegmentedController but the user can choose the segment and
One of our user did an insert statement in development server. The insert worked
I did this: [User.first, User.last].to_xml and got this: <users type=array> <user> <created-at type=datetime>2010-03-16T06:40:51Z</created-at> <id
Please note that I did ask this on Super User and received absolutely no
I'm a Git user trying to use Mercurial. Here's what happened: I did a
I'm experiencing some behavior I did not expect. I have a synchronous procedure that
This is a security question, What if I give to the user: a sample
I have used the jquery-ui to autocomplete an input box and set a hidden
I want to terminate a number of processes, but I want to give each

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.