Category Archives: RangeValidator

RangeValidator

[RESOLVED]How can i validate user input is in correct locale ?

Hi,

I have set my regional settings to France (fr-FR) and the number would be for example 3,11 . 

How can i make it so that if the user enters 3.11 (decimal)  in a textbox then an error is popped up to say that the number format is incorrect .

thanks

Salut, you can use ControlValidators.

For example 

<asp:textbox id="textbox1" runat="server"/>
<asp:RangeValidator id="valRange" runat="server"
ControlToValidate="textbox1" Type="Double" 
ErrorMessage="Wrong format!" Display="static">*</asp:RangeValidator>

where Type could be also set as  "Currency", depends on your requirements.

Also make sure you set proper culture in the web.config file

<globalization culture="fr-FR" uiCulture="fr-FR" />

Hi,

thanks for the reply , but is there an example using <asp:RangeValidator> which validates on the current browser culture , as i cant see how it will exactly work.

I can get the culture in javascript, so i was thinking could i call onblur and validate the input value ?

thanks

What about the example above, doesn’t it clear enough? There is a lot of documentation as well as samples on the internet regarding this matter.

As in case of javascript you most likely need to replace "," by a "." and check if it is a decimal number 

e.g. using jquery

$.validator.methods.range = function (value, element, param) {
    var globalizedValue = value.replace(",", ".");
    return this.optional(element) || (globalizedValue >= param[0] && globalizedValue <= param[1]);
}
 
$.validator.methods.number = function (value, element) {
    return this.optional(element) || /^-?(?:d+|d{1,3}(?:[s.,]d{3})+)(?:[.,]d+)?$/.test(value);
}

Source: http://rebuildall.umbraworks.net/rebuildall/2011/03/02/jQuery_validate_and_the_comma_decimal_separator 

or using javascript (e.g. using parseFloat())

function isNumber(n) {
n = n.replace(",", "."); return !isNaN(parseFloat(n)) && isFinite(n); }

Source: http://stackoverflow.com/questions/18082/validate-decimal-numbers-in-javascript-isnumeric 

It’s also possible to validate currency (fixed number of digits after comma)

http://stackoverflow.com/questions/18480658/decimal-validation-in-the-textfield-using-javascript-or-jquery 

Thanks for that . 

[RESOLVED]WebNumericEdit control in Asp.net

Hi All,

             I am facing a problem while using WebNumericEdit in my asp.net code.  I want it to accept values between -9999999999999999.99

and 9999999999999999.99. But it is not working as i wish. I have set its data mode as Decimal. I have to accept only two digits after decimal not more than that. 

For example if i enter value as -999999999999999.94 it automatically convert it in to -1000000000000000 which i don’t want. It should accept it as it is. I have set it Max value to 9999999999999999.99 and Min value to -9999999999999999.99.

Kindly help and please tell me why it is always rounding off the number.

Hi,

Please refer to MaskedEdit.

MaskedEdit is an ASP.NET AJAX extender that attaches to a TextBox control to restrict the kind of text that can be entered.            MaskedEdit applies a "mask" to the input that permits only certain types of characters/text to be entered.            The
supported data formats are: Number, Date, Time, and DateTime.            MaskedEdit uses the culture settings specified in the CultureName property. If none is specified            the culture setting will be the same as the page:
English (United States).

More details, please refer to:

http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/MaskedEdit/MaskedEdit.aspx.

You can use asp.net validation to achieve this goal. Following code will restrict user within limits and don’t allowed to enter number more than 2 decimal places.

<asp:TextBox ID="txtAmount" runat="server" />
<asp:Button ID="btnSaveDetails" runat="server" Text="Submit" OnClick="btnSaveDetails_Click" />
<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" Display="Dynamic" ErrorMessage="Amount is required!" ControlToValidate="txtAmount"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="rvDecimal" ControlToValidate="txtAmount" runat="server" ErrorMessage="Please enter a valid amount." ValidationExpression="^(-)?d+(.dd)?$"></asp:RegularExpressionValidator>
<asp:RangeValidator runat="server" Type="Double" ControlToValidate="txtAmount" Display="Dynamic" MinimumValue="-9999999999999999.99" MaximumValue="9999999999999999.99" ErrorMessage="Value isn't in range!"></asp:RangeValidator>

Your code behind

protected  void btnSaveDetails_Click(object sender, EventArgs e)
{
            
}

[RESOLVED]disabled an validate requirefield from a aspx page

hi there 

i have a page in aspx default.aspx

and im using a control  autocomplete.ascx

so when i checked  a checkbox in my default.aspx  page i want to disabled a requirefield validator in the control autocomplete.ascx,,

but i have no idea how to do that ,

i want to when i checked a checkbox in my default.aspx do something like this

oncheckecd="disblevalidatefield"

function disabledvalidatefield 

some code to disabled the required field validator from my other page autocomplete.aspx

disable RequiredFieldValidator1 from autocomplete.ascx

and this is the autocomplete.ascx code

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Autocomplete.ascx.vb" Inherits="Controls_Autocomplete" %>
<INPUT id="hdnAuto" type="hidden" value="0" name="hdnAuto" runat="server">
<asp:textbox id="txtAutoComplete" runat="server"></asp:textbox><asp:dropdownlist id="txtAutoComplete_Combo" runat="server"></asp:dropdownlist><asp:hyperlink id="hplAutoCompleteWindow" runat="server">
<asp:Image id="imgAutoComplete" runat="server"></asp:Image>
</asp:hyperlink><asp:rangevalidator id="rvAutoComplete_Combo" runat="server" Enabled="False" CssClass="errorBullet"
Type="Integer" MaximumValue="2147483647" MinimumValue="1" Display="Dynamic" ControlToValidate="txtAutoComplete_Combo"
ErrorMessage="="></asp:rangevalidator>
<asp:Label ID="lblScriptReg" runat="server"></asp:Label>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"

ControlToValidate="txtAutoComplete" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>



any help will be really appreciate


many many thanks in advanced

check this

http://forums.asp.net/t/1776606.aspx/1

hope this helps…

but, how can i access to the requirefieldvalidator??? because im trying to disabled from another aspx page,, 

remember im trying to disabled from default.aspx a required field into  autocomplete.ascx

please help me, im lost right now

sebastian11c

but, how can i access to the requirefieldvalidator??? because im trying to disabled from another aspx page,, 

remember im trying to disabled from default.aspx a required field into  autocomplete.ascx

please help me, im lost right now

this should work

ValidatorEnable(document.getElementById("<%=RequiredFieldValidator2.ClientID %>"), false);

this will get the id of control required to access control from usercontrol

hope this helps…

Hi,

Check the below code!

//MyControl.ascx
//--------------------------

<asp:TextBox ID="txtAutoComplete" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
                            runat="server"
                            ControlToValidate="txtAutoComplete"
                            ErrorMessage="RequiredFieldValidator">
</asp:RequiredFieldValidator>

//myControl.ascx.cs
//---------------------------

public partial class MyControl : System.Web.UI.UserControl
    {
        public RequiredFieldValidator CustomRequiredFieldValidator
        {
            get
            {
                return RequiredFieldValidator1;
            }

            set
            {
                RequiredFieldValidator1 = value;
            }
        }
    }

//Default.aspx
//--------------
<%@ Register Src="~/MyControl.ascx" TagPrefix="uc" TagName="ccontrol" %>
<div>
        <uc:ccontrol runat="server" ID="myCustomControl" />
        <asp:CheckBox runat="server" Text="Disable Required Field Validator" OnCheckedChanged="Chk_Changed" />
</div>


//Default.aspx
//--------------
protected void Chk_Changed(object sender, EventArgs e)
        {
            myCustomControl.CustomRequiredFieldValidator.Enabled = false;
        }

Hope it helps u…

thanks for your help

many many thanks

thanks for your help

i have this default.aspx

<%@ Register Src="../Controls/Autocomplete.ascx" TagName="Autocomplete" TagPrefix="Ultra" %>

<Ultra:Autocomplete ID="acLinea" runat="server" AutoPostBack="false"
EnableViewState="False" ImageUrl="../images/folder_blue.gif" Required="true"
VisibleCombo="false" Width="200" BubbleFunction="fLinea"/>

i use this code in java to disabled the requirefield on my control autocomplete.ascx

 ValidatorEnable(document.getElementById("<%=acLinear.ClientID%>_rfvcontrolautocomplete"), false);

and that works

thanks for your time and help

sebastian11c

i have this default.aspx

<%@ Register Src="../Controls/Autocomplete.ascx" TagName="Autocomplete" TagPrefix="Ultra" %>

<Ultra:Autocomplete ID="acLinea" runat="server" AutoPostBack="false"
EnableViewState="False" ImageUrl="../images/folder_blue.gif" Required="true"
VisibleCombo="false" Width="200" BubbleFunction="fLinea"/>

i use this code in java to disabled the requirefield on my control autocomplete.ascx

 ValidatorEnable(document.getElementById("<%=acLinear.ClientID%>_rfvcontrolautocomplete"), false);

and that works

thanks for your time and help

Please mark as answer on the posts which helped u. this helps future reader to understand which post resolved the issue

[RESOLVED]GridView Maximum 3 Catractere

Using VS2010, Asp.Net4, C#, 

I would like the gridview every field had a maximum of 3 characters, all fields, editing mode, enter only accept 3 character.

Actually what I would like is to be able to allow some columns in the gridview enter only 3 characters

Try this way 

<asp:TemplateField HeaderText="UnitsInStock" SortExpression="UnitsInStock">
                    <EditItemTemplate>
                        <asp:TextBox ID="xxx" runat="server" Text='<%# Bind("xxx") %>'></asp:TextBox>
                        <asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Not in the valid range"
                            ControlToValidate="xxx" MinimumValue="0" MaximumValue="3" ForeColor="Red"></asp:RangeValidator>
                    </EditItemTemplate></asp:TemplateField>

Hi Rames

I’m using BoundField, is possible

<asp:BoundField DataField="Nota" HeaderText="Nota" SortExpression="Nota" </asp:BoundField>

Yes you can do this.please look this sample , the you can do it . 

http://www.codeproject.com/Articles/203892/Required-BoundField-in-Gridview 

Hi Rames
Thanks for the help, but I could not get the example to work (I’m a mere mortal)

Have you looked at this post?

http://forums.asp.net/t/1256121.aspx/1

 

[RESOLVED]ValidatorCalloutExtender displays under textbox

I have multiple textboxes on a page with ValidatorCalloutExtender when it displays the popup the pop up sits under another txtbox instead of covering the textbox ,

Do i adjust the z-index or something?

thanks

Glen

 

A simple way to resolve this kind of problem, we should set its z-index .   Just like this,  object.style.zIndex = index.

For more details , here is the
document
.

http://forums.asp.net/t/1078345.aspx/1

 

hi..

You have an option to change the display side .You can display the callout extender below the textbox ..

For more refer the below links..

http://www.dotnetcode.in/2011/12/css-for-ajax-validatorcalloutextender.html

I have changed the z:index in the css file but still no go,
Thanks
I just can't to get it, I have the txtboxes set as 0 zindex any lower and chrome doen'st allow you to click on them
 
<div class="utxtw2pos">
                <asp:Label ID="lblw2" runat="server" Text="Width: "></asp:Label><asp:TextBox ID="wid2"
                    runat="server" BorderColor="#0099FF" BorderStyle="Groove" BorderWidth="2px" Width="50"
                    TabIndex="4" MaxLength="4"></asp:TextBox>
                     <asp:RequiredFieldValidator ID="RFwid2" runat="server" ErrorMessage="*" SetFocusOnError="True"  ControlToValidate="wid2" Display="Dynamic" ></asp:RequiredFieldValidator>
           
                    <asp:RangeValidator ID="RVwid2" runat="server" ErrorMessage="Wrong Width!" MaximumValue="1400" MinimumValue="100" SetFocusOnError="True" Type="Integer" ControlToValidate="wid2" Display="None"></asp:RangeValidator>
             <asp:CompareValidator ID="RCwid2" runat="server" ErrorMessage="Must be less than Length 1" Operator="LessThan" Type="Integer" ControlToCompare="len" ControlToValidate="wid2" Display="None"></asp:CompareValidator>
                          <asp:ValidatorCalloutExtender ID="vcbwid2V" runat="server" CssClass="vcall" TargetControlID="RVwid2">
                          </asp:ValidatorCalloutExtender>
                            <asp:ValidatorCalloutExtender ID="vcbwid2C" runat="server" CssClass="vcall" TargetControlID="RCwid2">
                          </asp:ValidatorCalloutExtender>
  </div>
        .vcall div, .vcall td
{
    border: solid 1px #999999;
    background-color: #ECFFFF;
     z-index: 5000;
}
        .vcall .ajax__validatorcallout_popup_table
        {   z-index: 5000;
            display: none;
            border: none;
            background-color: transparent;
            padding: 0px;
        }
        .vcall .ajax__validatorcallout_popup_table_row
        {
            vertical-align: top;
            height: 100%;
            background-color: transparent;
            padding: 0px;
        }
        .vcall .ajax__validatorcallout_callout_cell
        {
            width: 20px;
            height: 100%;
            text-align: right;
            vertical-align: top;
            border: none;
            background-color: transparent;
            padding: 0px;
        }
        .vcall .ajax__validatorcallout_callout_table
        {
            height: 100%;
            border: none;
            background-color: transparent;
            padding: 0px;
        }
        .vcall .ajax__validatorcallout_callout_table_row
        {
            background-color: transparent;
            padding: 0px;
        }
        .vcall .ajax__validatorcallout_callout_arrow_cell
        {
            padding: 8px 0px 0px 0px;
            text-align: right;
            vertical-align: top;
            font-size: 1px;
            border: none;
            background-color: transparent;
        }
        .vcall .ajax__validatorcallout_callout_arrow_cell .ajax__validatorcallout_innerdiv
        {
            font-size: 1px;
            position: relative;
            left: 1px;
            border-bottom: none;
            border-right: none;
            border-left: none;
            width: 15px;
            background-color: transparent;
            padding: 0px;
        }
        .vcall .ajax__validatorcallout_callout_arrow_cell .ajax__validatorcallout_innerdiv div
        {
            height: 1px;
            overflow: hidden;
            border-top: none;
            border-bottom: none;
            border-right: none;
            padding: 0px;
            margin-left: auto;
        }
        .vcall .ajax__validatorcallout_error_message_cell
        {
            font-family: Verdana;
            font-size: 10px;
            padding: 5px;
            border-right: none;
            border-left: none;
            width: 100%;
        }
        .vcall .ajax__validatorcallout_icon_cell
        {
            width: 20px;
            padding: 5px;
            border-right: none;
        }
        .vcall .ajax__validatorcallout_close_button_cell
        {
            vertical-align: top;
            padding: 0px;
            text-align: right;
            border-left: none;
        }
        .vcall .ajax__validatorcallout_close_button_cell .ajax__validatorcallout_innerdiv
        {
            border: none;
            text-align: center;
            width: 10px;
            padding: 2px;
            cursor: pointer;
        }

Hi,

Please debug with IE Deeloper Tools. Check which css you should be change.

For details, please refer to:

http://msdn.microsoft.com/en-us/library/ie/gg589507(v=vs.85).aspx.

Any more question, please feel free to reply.

This didn’t help and only confused me more,

 

I have sorted it by changing all my z-indexes on my divs

Hi,

Please make sure the callout z-index is higher than texbox.

Any more question, please feel free to reply.

I layed my divs z-indexes so as you headed to the right the lower the z-index got

.ctxtlpos {
	position: absolute;
	z-index: 4;
	left: 239px;
	top: 308px;
}

.ctxtlposro {
	position: absolute;
	z-index: 3;
	left: 273px;
	top: 356px;
}

[RESOLVED]OnkeyPress causing Error

<asp:TemplateField>
<ItemTemplate>
<table>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("BattryName") %>'></asp:Label>
</td>
<td>
<asp:TextBox ID="t1" runat="server" onkeyup="Check(event,this);" onkeypress="Check(event,this);"> </asp:TextBox>

<%--<asp:RangeValidator ID="RangeValidator1" ControlToValidate="t1" MinimumValue="0" MaximumValue='<%# Bind("Available") %>' runat="server" ErrorMessage="Error" ForeColor="Red"></asp:RangeValidator>--%>

</td>
<td>
/<asp:Label ID="Label1" runat="server" Text='<%# Bind("Available") %>'>></asp:Label>
</td>
<td>
<asp:Label ID="Label3" runat="server"> </asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
--------------------
<script language="javascript" type="text/javascript">
function Check(e,control) {
try {
var maxvalue = document.getElementById(control.id.replace('t1', 'Label1')).innerHTML;

if ((e.keyCode < 47 || e.keyCode < 58) || e.keyCode == 8)
{
var textvalue=control.value;
if (textvalue > maxvalue)
{
control.value = textvalue.substring(0, textvalue.length - 1);
}
}
else {
control.value = control.value.substring(0, control.value.length - 1);
}
}
catch(err)
{alert(err); }
}
</script>

I want to restrict the user for entering maximum value into that textbox .. when i used only keyup event then it work fine .. but when i used keypress event it do not work.

Thanks

Hi,

For your requirement you can use "RangeValidator"ap.net control but the only thing you missed here is specifying Type of the value check.

<asp:TemplateField>
<ItemTemplate>
<table>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("BattryName") %>'></asp:Label>
</td>
<td>
<asp:TextBox ID="t1" runat="server" onkeyup="Check(event,this);" onkeypress="Check(event,this);"> </asp:TextBox>

<asp:RangeValidator ID="RangeValidator1" ControlToValidate="t1" Type="Integer" MinimumValue="0" MaximumValue='<%# Bind("Available") %>' runat="server" ErrorMessage="Error" ForeColor="Red"></asp:RangeValidator>

</td>
<td>
/<asp:Label ID="Label1" runat="server" Text='<%# Bind("Available") %>'>></asp:Label>
</td>
<td>
<asp:Label ID="Label3" runat="server"> </asp:Label>
</td>
</tr>
</table>
</ItemTemplate>

This will work for you.

I know RangeValidator will work .. but I do not want to use it..

I want to validate using keypress and keyup event

Thanks

Why do you need to use/handle both?

suppose max value is 10

when i just press single number like ’2′ it work fine but when i continusly press ’22222222222′ then it donot raise error  that’s why i need keypress event to be worked

Thanks

Hi VimalBau,

which browser you are currenlty using? actually keypress event is NOT supperted in some browser, instead keyup/keydown is used in most browsers. and you are also using raw javascript,which may be browser specific, why do’t you try jQuery? it will support
maximum numbers of browser and its events are also supported in most browsers.

http://api.jquery.com/keypress/ 

http://www.w3schools.com/jquery/event_keypress.asp

From what your issue is “OnkeyPress causing Error”.      

Firstly, I would suggest you to try the following workaround:

function Check(e, control) {

            try {

                var maxvalue = document.getElementById(control.id.replace('t1', 'Label1')).innerHTML;

                //enter 0-9 Tab

                if ((e.keyCode > 47 || e.keyCode < 58) || e.keyCode == 8) {

                    var textvalue = control.value;

                    if (textvalue > maxvalue) {

                        control.value = textvalue.substring(0, textvalue.length - 1);

                    }

                    else {

                        control.value = control.value.substring(0, control.value.length - 1);

                    }

                }

                else {

                    throw "error-- enter number";

                }

            }

            catch (err)

            { alert(err); }

        }

 i hope it helps you.

[RESOLVED]Validate Date Textbox on TextChanged event

I have a date textbox which i want to validate on textchanged event or any other text event. I do not want to wait to validate this date textbox till the Submit button is clicked. I want the following validation to be done to the date textbox.

<asp:RangeValidator ID="rvDate" runat="server" ControlToValidate="txtBeginDate"
                                            ErrorMessage="Date format should be MM/DD/YYYY. (01/01/1900 - 01/01/3000)." MaximumValue="01/01/3000"
                                            MinimumValue="01/01/1900" SetFocusOnError="True" Display="None"  Type="Date"></asp:RangeValidator>
                         <asp:RequiredFieldValidator ID="rfvbeginDate" runat ="server" ControlToValidate ="txtBeginDate" ErrorMessage ="Effective begin date is required." Text ="" Display ="None" SetFocusOnError="True" ></asp:RequiredFieldValidator>

Please let me know how to do this. Any replies appreciated.

Thanks,
Joe

may i suggest you to use a calender control and set the min and max date so that it wont be enable to select

there are plenty of jquery calendet controls available on net

Hi,

You can check this-

http://forums.asp.net/t/1303019.aspx

try this. This method allows you to validate on textbox focus lost.

On page load add this.

txtDOB.Attributes.Add("OnBlur", "return fnValidateDOB()")

In design add this code to javascript

 <script type="text/javascript">
 function fnValidateDOB() {
            if (document.getElementById("<%=txtDOb.ClientID%>").value != "") {
                var dtText = document.getElementById("<%=txtDOb.ClientID%>").value;
                if (isValidDate(dtText)) {

                } else {
                    alert("Date format invalid. Please enter date format in mm/dd/yyyy!");
                    document.getElementById("<%=txtDOb.ClientID %>").value = "";
                    document.getElementById("<%=txtDOb.ClientID%>").focus();
                    return false;
                }
            }
        }


 function isValidDate(sText) {
            var reDate = /(?:0[1-9]|1[0-2])/(?:0[1-9]|[12][0-9]|3[01])/(?:19|20d{2})/;
            return reDate.test(sText);
        }

try this. This method allows you to validate on textbox focus lost.

On page load add this.

txtDOB.Attributes.Add("OnBlur", "return fnValidateDOB()")

In design add this code to javascript

 <script type="text/javascript">
 function fnValidateDOB() {
            if (document.getElementById("<%=txtDOb.ClientID%>").value != "") {
                var dtText = document.getElementById("<%=txtDOb.ClientID%>").value;
                if (isValidDate(dtText)) {

                } else {
                    alert("Date format invalid. Please enter date format in mm/dd/yyyy!");
                    document.getElementById("<%=txtDOb.ClientID %>").value = "";
                    document.getElementById("<%=txtDOb.ClientID%>").focus();
                    return false;
                }
            }
        }


 function isValidDate(sText) {
            var reDate = /(?:0[1-9]|1[0-2])/(?:0[1-9]|[12][0-9]|3[01])/(?:19|20d{2})/;
            return reDate.test(sText);
        }

Just place this code and change messages and controls naming. Your task will be done whith date range check.

asp:RequiredFieldValidator ID="rfvDateOfRetirement" runat="server" ControlToValidate="txtBeginDate"
            Display="Dynamic" ErrorMessage="Date Of Retirement is required" ValidationGroup="Emp"></asp:RequiredFieldValidator>
        <asp:RegularExpressionValidator runat="server" ValidationExpression="(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20|30)dd"
            ControlToValidate="txtBeginDate" ErrorMessage="Invalid Date Format(MM/dd/yyyy)"
            Display="Dynamic" SetFocusOnError="True" ID="revDateOfRetirement" ValidationGroup="Emp"></asp:RegularExpressionValidator>

Hope that your problem will be solved. 

Textbox NumericUpDownExtender RangeValidator js error

Using toolkit version 3.5.60919

I have the following controls on a content page..

<asp:ImageButton ID="QtyUp" runat="server"
                 AlternateText='<%$ Resources:Resource, QtyUp %>'
                 ToolTip='<%$ Resources:Resource, QtyUp %>' />
<asp:TextBox ID="ItemQty" runat="server" style="text-align: center;"
             Text="1" Width="15" />
<asp:ImageButton ID="QtyDown" runat="server"
                 AlternateText="<%$ Resources:Resource, QtyDown %>"
                 ToolTip='<%$ Resources:Resource, QtyDown %>' />
<asp:RangeValidator ID="ItemQtyRangeValidator" runat="server" SetFocusOnError="true"
                    ControlToValidate="ItemQty" Type="Integer" Display="Dynamic"
                    MinimumValue="1" MaximumValue="20"
                    ErrorMessage="<%$ Resources:Resource, QtyInvalid %>" />
<ajax:NumericUpDownExtender ID="ItemQtyUpDown" runat="server"
                            TargetControlID="ItemQty"
                            Minimum="1" Maximum="20"
                            TargetButtonDownID="QtyDown"
                            TargetButtonUpID="QtyUp" />
<ajax:RoundedCornersExtender ID="RCEqty" runat="server"
                             TargetControlID="ItemQty" BorderColor="Black"
                             Radius="4" Corners="All" />

When I run this, I get an error..

Microsoft JScript runtime error: Unable to get value of the property ‘srcElement’: object is null or undefined

It highlights some code in the framework..

function ValidatorOnChange(event) {
    if (!event) {
        event = window.event;
    }
    Page_InvalidControlToBeFocused = null;
    var targetedControl;
 if ((typeof(event.srcElement) != "undefined") && (event.srcElement != null)) {         targetedControl = event.srcElement;
    }
    else {
        targetedControl = event.target;
    }

IF I remove the NumericUpDownExternder, it works fine..

Any ideas?

Thanks for the reply, but it didn’t resolve the problem. 

My namespace is set up in web.config, so order at top of page isn’t relevant.    

I tried adding the javascript to the head content section and it made no difference.

I did encounter another problem though..  If I enable the compatible view, the roundedcornersextender causes an error.

          c.insertBefore(k,n)

No idea where that is, just in the middle of the roundedcornersextender js.

[RESOLVED]positive value validation

 var price = parseInt($(‘#tbPrice’).val());

In this code , I’m getting negative value also, Is there any way to prevent -ve values as parseInt not preventing it.

I can do that with if condition like if(price>0) or math.Abs() is there any other way.

From Code Befind you can set positive value validation

int price= Convert.ToInt32(tblprice.text);

if( price > 0 )

{

Response.Write("Positive Value") ;

}

else

{

Response.Write("Negative Value") ;

}

My friend , Please Mark as Answer if find helpful

var price = parseInt($('#tbPrice').val());

or

var price = Number($('#tbPrice').val());

if (price >= 0)
alert("Positive");
else
alert("Negative");

You can use a Range Valiator to check for value greater than zero –

<asp:RangeValidator id="Range1"  ControlToValidate="TextBox1"  MinimumValue="0"   MaximumValue="2147483647"  Type="Integer" Text="The value must be integer and greater or equal than 0" runat="server"/>