validation

Should I always call Page.IsValid in ASP.NET WebForms C#?

I know to never trust user input, since undesirable input could be compromise the application's integrity in some way, be it accidental or intentional; however, is there a case for calling Page.IsValid even when no validation controls are on the page (again, I know its bad practice to be trusting user input by omitting validation)? Does ...

An example of xVal with ASP.NET WebForms?

This is a two part question. Is it possible to take advantage of xVal's automatic client side validation with ASP.NET WebForms? If so, are there any examples available? I imagine that it would be possible to extend xVal to include ASP.NET Validator controls. These controls would be the WebForms equivalent of <%= Html.ClientSideValida...

C# interop - validate object exists

I would like to use a COM object in my application. How can I make sure the object is registered in the machine? The only solution I found (also on SO) was to use a try-catch block around the initialization: try { Foo.Bar COM_oObject = new Foo.Bar(); } catch (Exception ee) { // Something went wrong during init of COM object }...

Should validators in spring access the database?

I'm not really sure if it's a good design decision to make the validators validate commands based on the state of the database. For example if I need to validate a User bean besides checking if the email and username are empty etc. I also need to reject values if they are already used. Should this kind of logic go in the validators or th...

How do I make this regex more general, sometimes it works and sometimes it doesn't

I have the following regex that I am using in a java application. Sometimes it works correctly and sometimes it doesn't. <!-- <editable name=(\".*\")?> -->(.*)<!-- </editable> --> Sometimes I will have whitespace before/after it, sometimes there will be text. The same goes for the region within the tags. The main problem is that name...

Handling error messages using asp.net

Hi, I've an asp.net page having a server side submit button and 2 textboxes which accept only numeric values.Am also using asp.net validation controls. If the user types in non-numeric data in both the textboxes, how do i show only 1 error message on the page saying: "Only numeric values are allowed." And I want to achieve this without...

What are the common practices for notifying a user of invalid input?

In my company, I've seen several approaches for notifying a user when their input is invalid (our validation is generally done when the user clicks some form of a "Submit" button). Here are the most common approaches I've seen: Using the ErrorProvider class to communicate which controls contain invalid input. (this is my current pref...

using the jquery validation plugin, how can I add a regex validation on a textbox?

Hi, I am using the jquery validation plugin from: http://bassistance.de/jquery-plugins/jquery-plugin-validation/ How can I add a regex check on a particular textbox? I want to check to make sure the input is alphanumeric. ...

Validator validating on page load

Hi, I have a RequiredFieldValidator on a textbox and it seems to be firing when the page loads. If however, I set the Display="Static", this no longer occurs, its only when Display="Dynamic" My problem though, is I also have a custom validator on the same textbox control so If I set the display to dynamic on both of these controls, bo...

Validate field value using another field

Hi, I am trying to validate my model, I am using CakePHP 1.2.3.8166 and mysql 5 I have my model definied as it: class Actividad extends AppModel { var $name = 'Actividad'; var $validate= array('maxfield' => array( 'rule'=> array('chkValue'), 'message'=>'i2' )); function chkValue($data){ return $data["maxfield"]>=$data["minfi...

Validation in cakephp

Hi, I'm trying to perform validation in the login page for the name,email and password fields. If the input fails validation,the error message should be displayed. But here,when I fill in the details and submit, it is redirected to the next page. Only the value is not saved in the database. Why is the message not displayed? This is my...

Regular Expression to validate a timestamp

Hi, I need a regular expression to validate a timestamp of the format, using Javascript: YYYY/MM/DD HH:MI:SS I tried cooking up a few, but seems my regex skills fail to cover something or other. Please give me a reference or way to do it. P.S. : I mention regex, only as a suggestion. Im using Javascript and welcome any alternati...

Silverlight 3: Expose Validation.GetHasError on custom control

I have written a custom UserControl that is embedded into another UserControl. Something like the simple diagram below. UserControl_A UserControl_B TextBox_1 CheckBox_1 Button_Save In UserControl-B the validation is working reasonably well but I want to check for errors in the logic of UserControl-A ( OnSaveClick event of t...

Dynamically change ajax toolkit ValidatorCalloutExtender

Hey everyone, I'm using the ajax toolkit's ValidatorCalloutExtender to display error messages on a textbox. The ValidatorCalloutExtender is extending on a RegularExpressionValidator that is validating the textbox. The problem I am having is that I need to dynamically change the ValidationExpression and ErrorMessage depending on what ...

jQuery Validation plugin minLength for checkboxes

Hello all, this is my first post here on stackoverflow and am very impressed by the site! My question is about the jQuery Validation plugin...specifically about the minLength method. I have a group of checkboxes and i want to know if at least 2 boxes were checked. http://docs.jquery.com/Plugins/Validation/Methods/minlength#length at t...

jquery validation - show error icon next to control and error summary on top

Hi, I am interesting in using Jquery Validation in the app (ASP.NET) I am currently developing. Using the default settings in JQuery really messes up the layout of the form. I wanted to show the error summary on the top of the form and have a icon floating next to the control to indicate the error input. I know how to get the error ...

asp.net MVC RuleViolation.ErrorMessage into Html.ValidationMessage

Hi, I want to use the error message returned by a RuleViolation as the validationMessage of the Html.ValidationMessage(modelName, validationMessage). Simple Example: Person.cs public partial class Person { public bool IsValid { get { return (GetRuleViolations().Count() == 0); } } public...

How to round-trip view-only data between views and controllers

I'm passing data between my controller and my view using a ViewModel class. When there are validation errors, I return the ViewModel back to the view so the user can see the errors. I'm having trouble figuring out the best way to deal with the data that is only passed from the controller to the view, which isn't passed back to the contr...

Changing jquery validation error message

Hi, I'm using jQuery and the minlength method for the validation plugin rules: { checkboxes: { required:true, minlength: 3 } } This works how i want it to, BUT the error message I'm getting is "Please enter at least 3 characters." How do I instead say, "Please check at least 3 box...

How can I validate a property against a regular expresssion and still allow it to be null or empty?

I'm using the Validation Application Block from Microsoft. I have a string property which holds a phone number. I have a RegexValidator on it which works pretty well for ensuring only phone number type strings are in the property, but the property should also allow values that are null or an empty string. Currently the this validator ...