This is a migrated thread and some comments may be shown as answers.

Clientside check on empty controls

1 Answer 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chad Johnson
Top achievements
Rank 1
Chad Johnson asked on 14 Oct 2008, 04:45 PM
Greetings,

I have a RadGrid that does add, edit, and deleting.  Thus far, I have done everything serverside on my checks, but I need to do a check clientside and put out an alert for when someone doesn't fill in something.  My grid has the following, which isn't much for input fields.  It's simply a normal bound column, which is a textbox when adding or editing, and then a template field for a checkbox, but that doesn't have to be checked for validation.  I guess my question is, how do you check the textbox for validation using javascript?  I've tried several ways, but I get errors.  Here is the way I have been trying:

if (button.get_commandName() == "PerformInsert")  
        {  
            var txtid = "ctl00_ctl00_cphContent2_cphAITContent_ctl00_rgdStatusList_ctl00_ctl02_ctl03_ctl01";  
            var txt = $find(txtid);  
            if (txt.value.length == 0)  
            {  
                alert("You must type something in for Status Description field.");  
            }  
        } 

In my code, I found the id of the textfield that is within the grid, then I try to find it, but this does nothing.  Anyone have any ideas?  Thanks.

Chad

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 15 Oct 2008, 06:22 AM
Hello Chad,

    You can refer to the following code library submission link which demostrates on how to access the editor value when item is in edit/insert mode. The client id of the textbox editor is stored in window object attribute and the textbox is found on the client calling the document.getElementById(id) javascript method. After accessing the control, you can probably display the alert message as required.
Retrieving grid editor value client side

Thanks
Princy.

Tags
Grid
Asked by
Chad Johnson
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or