SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Default value

  1. #1
    SitePoint Member
    Join Date
    Jan 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default value

    Hi guys, I'm brand new here and found this awesome forum that can help me.

    So here is the question. I have a form that has a javascript math built in and the math required a value to compute properly. So what I did is I set each fields to be computed default to "0" (zero). The challenge is what if a user accidentally delete one of the required field? I mean how do I make the value re-appear once user tab over to the next field?

    Greatly appreciated with the help

  2. #2
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,564
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Code:
    <input type="text" id="number" value="0" onblur="test();"/>
    ...
    <script type="text/javascript">
    function test()
    {
     var number=document.getElementById(number);
     if(number.value=='')
       number.value='0';
    }
    </script>
    Something like that?

    Cheers.
    Twitter-@Ryan_Reese09
    http://www.ryanreese.us -Always looking for web design/development work


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •