Skip to content
Advertisement

Tag: validation

Laravel Form Validation, fail if not empty

I have an input field which needs to be empty, otherwise I want the validation to fail. This is an attempt at stopping spam through a contact form. I’ve looked at the documentation for the validation but there’s nothing to do this, other than the “max” rule, but this doesn’t work. Any other options? Answer In the method where you

Laravel: Validation unique on update

I know this question has been asked many times before but no one explains how to get the id when you’re validating in the model. My validation rule is in the model so how do I pass the ID of the record to the validation rule. Here is my models/User models/BaseModel Answer One simple solution. In your Model In your

PHP Regular Expression for Bengali Word/Sentence

I am developing a web application using PHP 5.3.x. Everything is working fine, but unable to solve an issue due to regular expression problem with Bengali Punctuation. Following is my code: Whether I pass Bengali word or not, it always returns false. In JavaEE application I used this Regular Expression But in PHP it not working! Anyways how do I

Symfony2 Validating an optional field

In my form, I have a field with required option set to false, this field is optional. However, I would like to have a notBlank validation on this field when the field is used: Right now, I can’t use the validation constraint NotBlank because it will cause my form validation to fail when the field is unused. I tried something

php date validation

Im trying to to set up a php date validation (MM/DD/YYYY) but I’m having issues. Here is a sample of what I got: Answer You could use checkdate. For example, something like this: A more paranoid approach, that doesn’t blindly believe the input:

PHP checkdate variants

I found a php function checkdate() , but strangely enough it only seems to accept data in format of int $month , int $day , int $year. However I am passing the date as a string (example “2012-06-13”) …

Advertisement