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

RadComboBox Setting style border using javascript

2 Answers 366 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
JaiChandra Chilumuru
Top achievements
Rank 1
JaiChandra Chilumuru asked on 20 Jan 2010, 06:22 PM
I am trying to set border style of the RadComboBox control on client side to red on fail of validation. I am using Custom validator control, but the border doesnt seem to change. Can you please review my code and let me know what am I doing?

 <telerik:RadComboBox runat="server" ID="radCbLicenseSt" Width="55px" Height="300px" ></telerik:RadComboBox> 
<asp:CustomValidator  ID="cvLicensest" runat="server" ControlToValidate="radCbLicenseSt" ValidateEmptyText="true"  ClientValidationFunction="ReqFieldValidationCBox" CssClass="error" EnableClientScript="true" Display="Dynamic" ValidationGroup="Enrollment" />  
 
 
 
 

function ReqFieldValidationCBox(source, arguments)  
{  
    var Cbox = $find(source.controltovalidate);  
    if (Cbox)  
    {  
        if (Cbox.get_value() == ""
        {   
            Cbox.get_inputDomElement().style.bordercolor = "red"
            Cbox.get_inputDomElement().style.borderwidth = "1px";                       
            arguments.IsValid = false;  
        }  
        else  
        {  
            arguments.IsValid = true;  
        }  
    }  
}  

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 21 Jan 2010, 06:41 AM
Hello JaiChandra,

I tried following code in order to set the border for the combobox. Give a try with this.

Client Side Code:
 
    function ReqFieldValidationCBox(source, arguments) { 
        var Cbox = $find(source.controltovalidate); 
        if (Cbox) { 
            if (Cbox.get_value() == null || Cbox.get_value == "") { 
                Cbox._element.style.border = "solid 1px red"
                arguments.IsValid = false
            } 
            else { 
                arguments.IsValid = true
            } 
        } 
    } 

-Shinu.
0
JaiChandra Chilumuru
Top achievements
Rank 1
answered on 21 Jan 2010, 02:58 PM
Thank you. It worked.
Just a minor correction.. I added parenthesis to get_value
if (Cbox.get_value() == null || Cbox.get_value() == ""



Tags
ComboBox
Asked by
JaiChandra Chilumuru
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
JaiChandra Chilumuru
Top achievements
Rank 1
Share this question
or