Validating C# base class constructor parameter

After running Code Analysis in VS2010 beta (FxCop for previous versions) I’m getting the following warning: In externally visible method ‘Identity.Identity(WindowsIdentity)’, validate parameter ‘windowsIdentity’ before using it. The constructor is: public Identity(WindowsIdentity windowsIdentity) : base(windowsIdentity.Token) { init(); } for a class defined as: public class Identity : WindowsIdentity My question is, how do I validate … Read more

Overriding Form Validation messages on symfony2

How to override the form validation messages in symfony2. Though there is a validation.xml file related model classes. I think it validates a form based on html5. “Please match the requested format”, “Please fill out this field”. Is there any way to override this validation messages. Please help me in this regard, i am stuck … Read more

Check is a specific form field is valid

I’ve been searching for a while now and haven’t found a solution yet. I’m an ASP.NET and MVC4/Razor2 newbie, so I’m mostly editing the default project. Anyway, my issue is that I’m using Twitter Bootstrap and I need to add an error CSS class on a div if the under-laying field is not valid. So … Read more

Custom validation message for regex rule in Laravel?

Pretty basic question, I’m trying to customise the error message for a regex validation rule in Laravel. The particular rule is for passwords and requires the password to have 6-20 characters, at least one number and an uppercase and lowercase letter so I’d like to communicate this to the user rather than just the default … Read more

Do all valid emails contain at least one @ symbol?

I’m not trying to come up with full email validation. I’m trying to prevent a specific problem: I’ve had users use the contact form on my website, which asks for “Name“, “Email” and “Message“, and just by hilarious mistake, I get the info, “First Name“, “Last Name“, “Message“, and I think to myself, ‘Shit where … Read more

Validate only numbers

In one of my rails models I have this :only_integer validation: validates :number, presence: true, numericality: { only_integer: true } This validation also allows inputs like +82938434 with +-signs. Which validation should I use to only allow inputs without + – only numbers? Answer The documentation for only_integer mentions this regex : /\A[+-]?\d+\z/ It means … Read more

What is the event to catch form submission in Javascript?

A couple of questions here: I was wondering what event do I use to execute some Javascript on form submission (to do some validation)? Once I have done my validation, how do I then submit the form in Javascript ? Answer Let’s say you have a form named myForm: var form = document.getElementById(‘myForm’); To catch … Read more

How To Prevent Duplicate Email Addresses on a User Registration Form? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 8 years ago. Improve this question I want to prevent duplicate email addresses during registration. How would I go about validating the text box on … Read more