I have written a regular expression for AspxTextBox to validate decimal value as follows
<dx:ASPxTextBox ID="txtDecimal" runat="server">
<ValidationSettings ValidationGroup="g" RegularExpression-ValidationExpression="^\d+(\.\d{1,2})?$">
</ValidationSettings>
</dx:ASPxTextBox>
When I am entering the digits in the textbox directly it is validating as per required, but I have a group of buttons with 0-9 and a . button where user can input the text using those buttons, on clicking buttons and appending text in the textbox validation is unable to fire even if I enter wrong input, what might be the problem can some one help me
I suppose that DevEx library uses on change event to execute validation.
OnChange (and other Javascript events) are executed when control value is changed during user interaction and not when you change value programatically.
So, you need to execute it manually:
<dx:ASPxTextBox ID="txtDecimal" runat="server" ClientInstanceName="tb">
<ValidationSettings ValidationGroup="g" RegularExpression-ValidationExpression="^\d+(\.\d{1,2})?$"/>
</dx:ASPxTextBox>
<input type="button" onclick="tb.SetValue('10xyz');tb.Validate();"/>
Related
I have some ASP.NET CustomValidators with Display="Dynamic". The layout of the page requires that I use them like this without a ValidationSummary.
<asp:CustomValidator ID="vldFirstThree" ControlToValidate="txtFirstThree" runat="server" OnServerValidate="ValidateTextBox" ValidateEmptyText="true" ErrorMessage="Please enter the first three characters of the owner name.<br />" CssClass="error" Display="Dynamic" Enabled="true"/>
If the user leaves the field blank and clicks submit, the error text is displayed. If the user fixes the problem and then clicks submit again, the validation error text clears, but a second click is required to submit the page. I've tried writing some server-side code and some JavaScript to cause the validated TextBox to blur() before submitting, but I'm still running into the need to click twice: once to clear the message and again to submit.
Is there a way to clear the error text and perform the submit with one click?
The answer is the second one here: RequiredFieldValidator have to click twice.
I had to set EnableClientScript="false".
In web application, i place one panel in that one textbox wiht multiline property to true and one button. when i place default button property of panel to button, but it is not working it the textboxe multy line property is the reason? help me,
Check out this example, this might help you:
<div id="LoginForm">
<asp:Panel ID="Panel1" runat="server" DefaultButton="btnCustLogin">
<h1>User Login</h1>
<label>Email ID:</label>
<asp:TextBox ID="txtCustEmailID" runat="server" MaxLength="50"></asp:TextBox>
<asp:Button ID="btnCustLogin" runat="server" Text="Login" OnClick="btnCustLogin_Click"/>
</asp:Panel>
</div>
It is the expected behavior
Pressing the ENTER key with focus inside a multi-line textbox. In a
multi-line textbox, pressing the ENTER key should create a new line in
the textbox which is the expected behavior. In browsers where the
pressing the ENTER key inside a multi-line textbox triggers a post
back but you want the ENTER key to create a new line instead you can
attach a JavaScript function to the input control. The script should
capture the ENTER key and stop the post back. For example, you can use
the Attributes property collection to add client script for the
onKeyPress event.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.panel.defaultbutton.aspx
Within an ASP.Net application I have, there is a textbox that gets a date from a CalendarExtender. When the textbox is populated it checks that date with another date on the form and displays a modalpopupextender popup if the dates are wrong. However, I DO NOT want to allow user input into this textbox, so when I set the ReadOnly field to false and tried Enabled to false, it doesn't allow manual entry however it ALSO disabled the postback and will not call the TextChanged event to fire the modalpopupextender.
So is there a way to disable manual entry and not set it to ReadOnly?
I figured it out, simply enter onkeypress="return false;" within the HTML tag
Try this
<asp:textbox id="txt1" onfocus="blur()" runat="server"/>
this worked for me.
Add the below properties in the tag of textbox
onkeydown="return false" onpaste="return false"
ex:
<asp:TextBox ID="TillDate_TextBox" runat="server" onkeydown="return false" onpaste="return false"></asp:TextBox>
the first property block typing in textbox and the second property block pasting in it
I'm not familiar with the exact components you are using, however the usual way to accomplish things like this is the following. Have selecting the date on the calendar modify the value of a hidden form field. This will restrict the user from editing the value directly. Then create another element like a div or a span, and use javascript to update the span/div to the value selected on the calendar.
I have 2 user controls on registered on one aspx page.
UserControl1 us having one text box with require field and one submit button.
UserControl2 is also having one text box with requirefiled and save button.
Expected o/p is-
When I am clicking on any button out of 2(submit or save). Then only related text boxof that user control should be validate.
But the error is
Both text boxes are validate.
Please help me .
Set the ValidationGroup properties to limit which fields get validated when the buttons are pressed.
So for example, if these were contained within the first user control:
<asp:requiredfieldvalidator id="NameValidator"
controltovalidate="NameTextBox"
validationgroup="UserControlOne"
errormessage="required"
runat="Server" />
<asp:button id="Submit"
text="Submit"
causesvalidation="true"
validationgroup="UserControlOne"
runat="Server" />
Clicking the "Submit" button would only cause the validators that have UserControlOne specified as the ValidationGroup to validate.
Edit: When you call Page.Validate() you are validating every group on the page. Call the overloaded Page.Validate(validationGroup) to validate a specific one. e.g. Page.Validate("UserControlOne")
Hello, I have been having trouble with this for a while now. I have a bound textbox within a Detailsview, to which I have added a RegularExpressionValidator (REV). The Regular Expression used is [a-zA-Z]*
After running the Web Form, the Edit button opens the fields. Any entries made cause the REV error msg to be displayed when the Update button is pressed, irrespective of the validation. The Update button continues to be displayed until the Cancel button is selected and the original record is returned to the screen replacing any entries.
The RequiredFieldValidator works correctly.
Ray Brown
I would suggest you FilteredTextBoxExtender of Ajax Control Toolkit instead of using REV.
It gives you the option to validate the input for many types of validation for numeric, letter, or even custom types for example:
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<ajaxToolkit:FilteredTextBoxExtender ID="ftbe" runat="server"
TargetControlID="TextBox3"
FilterType="LowercaseLetters, UppercaseLetters" />