views:

8

answers:

0

this is my javascript code -

function ae_Validate(sender, args) {
        var cbs =  document.getElementsByTagName('input');
        args.IsValid = true;
        for (i = 0; i < cbs.length; i++) {
            if (cbs[i].type != 'checkbox') continue;
            if (!cbs[i].checked) continue;
            var price = document.getElementById(cbs[i].id.replace('a_id_', 'b_id_'));
            if (!Validate_Price(price)) args.IsValid = false;
        }            
    }

    function Validate_Price(price) {
        var iprice = price.value;
        iprice = deleteChrs(iprice);
        if (iprice.length == 0 || iprice<=0) {
            //add border error
            price.style.backgroundColor = 'yellow';
            return false;
        }
        price.style.backgroundColor = '';
        return true; 
    }

and this is my customvalidator that calls it -

<asp:TextBox ID="tbval" style="visibility:hidden; width:10px" runat="server" ValidationGroup="vgroup"></asp:TextBox>
<asp:CustomValidator ID="cv" runat="server" ControlToValidate="tbval"
ValidationGroup="vgroup" ValidateEmptyText="true" ClientValidationFunction="cv_Validate"></asp:CustomValidator

i have removed the "<" and ">" because this website wont let me put that in here. this code works perfect. I just want to convert this on my server side, in case someone does not have javascript enables browser.