Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Location
    Anchorage
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to find control in formview from javascript

    I'm trying to retrieve the value of a text box "txtDrumNumber" so I can run a validation script. I can't seem to get the correct method for this. Here is what has been suggested but didn't work.

    <script type="text/javascript">
    function isValidDrumNumber(sender, args) {
    var DrumNumber = fvAddNewDrum.FormviewRow.FindControl("txtDrumNumber").ClientID;
    var DrumString = DrumNumber.value;
    if (DrumString.length = 11) {
    return true;
    }
    else {
    DrumNumber.focus();
    args.IsValid = false;
    return false;
    }
    }
    </script>

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,858
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Code:
    var value=document.getElementById('myinput');
    alert(value);
    Code:
    <input type="text" name="myinput" id="myinput">
    The above should work in all cases(with no major errors in markup).
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Tags for this Thread

    Posting Permissions

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