As briefly explained in the topic I can't seem to have client side asp.net validators to work. Server side is all ok, infacat since the Page_Validators is undefined, the Page_IsValid is always true (clientside) so the client validation always pass BUT server side, after the postback that shouldn't occur, I get the correct error messages reported.
I copied exactly your example on demo page of RadInput validation do do further testing but with no results (I even stripped it down a basic 1 textbox + 1 validator, I tryed with standard asp textboxes, I searched the web for 4 hours now finding all kind of answers even in this forum, all with no luck).
Things I can say in advance:
- The .axd script resources all loads correctly (checked both in Google Chrome developers console and Firefox Firebug consol. No 404 or 500 errors)
- The ScriptResources.axd starts with those public js variables (no hint at Page_Validators there is it normal?)
- Checking with Google Chrome developers tools console for alert(Page_Validators.length) returns ReferenceError: Page_Validators is not defined
- If I set in the web.config <add key="Telerik.ScriptManager.TelerikCdn" value="Enabled" /> (instead of "Disabled") I also experience a js error: Uncaught ReferenceError: $telerik is not defined This doesn't happen in my real code btw, just happens on the page I copy/pasted from your on-line example to make tests (I will report the code down here). This means that somehow I fixed that second bug in my real project but I don't remember how.
- I tryed with both CDN enabled and disabled in the RadScriptManager.
- I tryed with both your Jquery and with Google CDN served JQuery (1.9.1)
I really don't know where else look at... after 4/5 unsuccessfull hours at a simple task like validation should be, even in the simpliest scenarios I tested, I really give up. Please give me some hint on where to look for more.
Here is the code:
The VB code is taken exactly from your example as well:
Thanks in advance... I really had other frustrating similar issues that went on for hours, but finally come to spot a solution. This time I'm really knocked down.
EDIT: as a side note I tryed an even more "minimalistic" test wit .NET script manager instead of RadScriptManager and it works perfectly. Checking in the Google js console for alert(Page_Validators.lenght); also returns correctly: 1
So the issue must be somewhere in the RadScriptManager OR in the RadAjax solution I guess.
This is the code:
I copied exactly your example on demo page of RadInput validation do do further testing but with no results (I even stripped it down a basic 1 textbox + 1 validator, I tryed with standard asp textboxes, I searched the web for 4 hours now finding all kind of answers even in this forum, all with no luck).
Things I can say in advance:
- The .axd script resources all loads correctly (checked both in Google Chrome developers console and Firefox Firebug consol. No 404 or 500 errors)
- The ScriptResources.axd starts with those public js variables (no hint at Page_Validators there is it normal?)
var
Page_ValidationVer =
"125"
;
var
Page_IsValid =
true
;
var
Page_BlockSubmit =
false
;
var
Page_InvalidControlToBeFocused =
null
;
var
Page_TextTypes = /^(text|password|file|search|tel|url|email|number|range|color|datetime|date|month|week|time|datetime-local)$/i;
- Checking with Google Chrome developers tools console for alert(Page_Validators.length) returns ReferenceError: Page_Validators is not defined
- If I set in the web.config <add key="Telerik.ScriptManager.TelerikCdn" value="Enabled" /> (instead of "Disabled") I also experience a js error: Uncaught ReferenceError: $telerik is not defined This doesn't happen in my real code btw, just happens on the page I copy/pasted from your on-line example to make tests (I will report the code down here). This means that somehow I fixed that second bug in my real project but I don't remember how.
- I tryed with both CDN enabled and disabled in the RadScriptManager.
- I tryed with both your Jquery and with Google CDN served JQuery (1.9.1)
I really don't know where else look at... after 4/5 unsuccessfull hours at a simple task like validation should be, even in the simpliest scenarios I tested, I really give up. Please give me some hint on where to look for more.
Here is the code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="Test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
<
telerik:RadStyleSheetManager
ID
=
"RadStyleSheetManager1"
runat
=
"server"
CdnSettings-TelerikCdn
=
"Enabled"
/>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
runat
=
"server"
ID
=
"RadScriptManager1"
/>
<
telerik:RadSkinManager
ID
=
"QsfSkinManager"
runat
=
"server"
ShowChooser
=
"true"
/>
<
telerik:RadFormDecorator
ID
=
"QsfFromDecorator"
runat
=
"server"
DecoratedControls
=
"All"
EnableRoundedCorners
=
"false"
/>
<
telerik:RadAjaxPanel
ID
=
"RadAjaxPanel1"
runat
=
"server"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
>
<
fieldset
>
<
legend
>Registration form</
legend
>
<
br
/>
<
table
border
=
"0"
cellpadding
=
"5"
>
<
colgroup
>
<
col
width
=
"100"
/>
<
col
width
=
"500"
/>
</
colgroup
>
<
tr
class
=
"FormContainer"
>
<
td
>
Name:
</
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"RadTextBox1"
runat
=
"server"
></
telerik:RadTextBox
>
<
asp:RequiredFieldValidator
ID
=
"TextBoxRequiredFieldValidator"
runat
=
"server"
Display
=
"Dynamic"
ControlToValidate
=
"RadTextBox1"
ErrorMessage
=
"The textbox can not be empty!"
></
asp:RequiredFieldValidator
>
</
td
>
</
tr
>
<
tr
class
=
"FormContainer"
>
<
td
>
Age:
</
td
>
<
td
>
<
telerik:RadNumericTextBox
ID
=
"RadNumericTextBox1"
runat
=
"server"
Type
=
"Number"
NumberFormat-DecimalDigits
=
"0"
>
</
telerik:RadNumericTextBox
>
<
asp:RequiredFieldValidator
ID
=
"NumercTextBoxRequiredFieldValidator"
runat
=
"server"
Display
=
"Dynamic"
ControlToValidate
=
"RadNumericTextBox1"
ErrorMessage
=
"Please, select an year number!"
></
asp:RequiredFieldValidator
>
<
asp:RangeValidator
ID
=
"NumericTextBoxRangeValidator"
runat
=
"server"
ControlToValidate
=
"RadNumericTextBox1"
ErrorMessage
=
"Year number should be a non negative less than 50."
Display
=
"Dynamic"
MaximumValue
=
"50"
MinimumValue
=
"0"
Type
=
"Double"
></
asp:RangeValidator
>
</
td
>
</
tr
>
<
tr
class
=
"FormContainer"
>
<
td
valign
=
"top"
>
Phone:
</
td
>
<
td
>
<
telerik:RadMaskedTextBox
ID
=
"RadMaskedTextBox1"
runat
=
"server"
Mask
=
"(###)-######"
>
</
telerik:RadMaskedTextBox
>
<
asp:RequiredFieldValidator
Display
=
"Dynamic"
ID
=
"MaskedTextBoxRequiredFieldValidator"
runat
=
"server"
ErrorMessage
=
"Please, enter a phone number."
ControlToValidate
=
"RadMaskedTextBox1"
></
asp:RequiredFieldValidator
>
<
asp:RegularExpressionValidator
Display
=
"Dynamic"
ID
=
"MaskedTextBoxRegularExpressionValidator"
runat
=
"server"
ErrorMessage
=
"Format is (###)-######"
ControlToValidate
=
"RadMaskedTextBox1"
ValidationExpression
=
"\(\d{3}\)-\d{6}"
></
asp:RegularExpressionValidator
>
</
td
>
</
tr
>
<
tr
class
=
"FormContainer"
>
<
td
valign
=
"top"
>
Email
</
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"Radtextbox2"
runat
=
"server"
></
telerik:RadTextBox
>
<
asp:RegularExpressionValidator
ID
=
"emailValidator"
runat
=
"server"
Display
=
"Dynamic"
ErrorMessage
=
"Please, enter valid e-mail address."
ValidationExpression
=
"^[\w\.\-]+@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*(\.[a-zA-Z]{2,3}){1,2}$"
ControlToValidate
=
"Radtextbox2"
>
</
asp:RegularExpressionValidator
>
<
asp:RequiredFieldValidator
ID
=
"Requiredfieldvalidator1"
runat
=
"server"
Display
=
"Dynamic"
ControlToValidate
=
"Radtextbox2"
ErrorMessage
=
"Please, enter an e-mail!"
></
asp:RequiredFieldValidator
>
</
td
>
</
tr
>
<
tr
class
=
"FormContainer"
>
<
td
>
Hire Date:
</
td
>
<
td
>
<
telerik:RadDateInput
ID
=
"RadDateInput1"
runat
=
"server"
DateFormat
=
"d"
MinDate
=
"01/01/1990"
MaxDate
=
"01/01/3000"
></
telerik:RadDateInput
>
<
asp:RangeValidator
ID
=
"DateInputRangeValidator"
runat
=
"server"
ControlToValidate
=
"RadDateInput1"
ErrorMessage
=
"Choose a date between 5th of January 2005 and 1st of September 2005"
Display
=
"Dynamic"
MaximumValue
=
"2005-09-01-00-00-00"
MinimumValue
=
"2005-01-05-00-00-00"
></
asp:RangeValidator
>
<
asp:RequiredFieldValidator
ID
=
"PickerRequiredFieldValidator"
runat
=
"server"
Display
=
"Dynamic"
ControlToValidate
=
"RadDateInput1"
ErrorMessage
=
"Please select a date"
></
asp:RequiredFieldValidator
>
</
td
>
</
tr
>
</
table
>
<
br
/>
<
br
/>
<
asp:CheckBox
ID
=
"CheckBox1"
runat
=
"server"
CssClass
=
"CheckBox"
Text
=
"Client Side Validation"
Checked
=
"True"
AutoPostBack
=
"True"
></
asp:CheckBox
>
<
br
/>
<
br
/>
<
asp:Button
ID
=
"Button1"
runat
=
"server"
Text
=
"Postback"
></
asp:Button
>
<
input
type
=
"reset"
value
=
"Reset"
/>
</
fieldset
>
</
telerik:RadAjaxPanel
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
></
telerik:RadAjaxLoadingPanel
>
</
form
>
</
body
>
</
html
>
The VB code is taken exactly from your example as well:
Imports
System
Imports
System.Collections
Imports
System.ComponentModel
Imports
System.Data
Imports
System.Drawing
Imports
System.Web
Imports
System.Web.SessionState
Imports
System.Web.UI
Imports
System.Web.UI.WebControls
Imports
System.Web.UI.HtmlControls
Partial
Public
Class
test
Inherits
System.Web.UI.Page
Private
Sub
CheckBox1_CheckedChanged(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
CheckBox1.CheckedChanged
MaskedTextBoxRequiredFieldValidator.EnableClientScript = CheckBox1.Checked
DateInputRangeValidator.EnableClientScript = CheckBox1.Checked
PickerRequiredFieldValidator.EnableClientScript = CheckBox1.Checked
TextBoxRequiredFieldValidator.EnableClientScript = CheckBox1.Checked
NumercTextBoxRequiredFieldValidator.EnableClientScript = CheckBox1.Checked
MaskedTextBoxRegularExpressionValidator.EnableClientScript = CheckBox1.Checked
NumericTextBoxRangeValidator.EnableClientScript = CheckBox1.Checked
Requiredfieldvalidator1.EnableClientScript = CheckBox1.Checked
emailValidator.EnableClientScript = CheckBox1.Checked
End
Sub
End
Class
Thanks in advance... I really had other frustrating similar issues that went on for hours, but finally come to spot a solution. This time I'm really knocked down.
EDIT: as a side note I tryed an even more "minimalistic" test wit .NET script manager instead of RadScriptManager and it works perfectly. Checking in the Google js console for alert(Page_Validators.lenght); also returns correctly: 1
So the issue must be somewhere in the RadScriptManager OR in the RadAjax solution I guess.
This is the code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test2.aspx.vb" Inherits="test2" %>
<!DOCTYPE html>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
asp:TextBox
ID
=
"test"
runat
=
"server"
></
asp:TextBox
>
<
asp:RequiredFieldValidator
ID
=
"TextBoxRequiredFieldValidator"
runat
=
"server"
Display
=
"Dynamic"
ControlToValidate
=
"test"
ErrorMessage
=
"The textbox can not be empty!"
></
asp:RequiredFieldValidator
>
<
asp:Button
ID
=
"but"
runat
=
"server"
Text
=
"submit"
/>
</
div
>
</
form
>
</
body
>
</
html
>