formapro / JsFormValidatorBundle

The Javascript validation for Symfony 2, 3 and 4 forms
MIT License
128 stars 57 forks source link

Html number field validation #67

Open eggp opened 9 years ago

eggp commented 9 years ago

Hello!

I tested with HTML5 number field, but do not work... (sry i little speak english :( ) my entity: ..... /* * @var integer * @Assert\NotBlank() * @Assert\Type(type="integer") * @Assert\Range(min="1",max="10") / private $columns; ....

form:

->add( "columns", "integer", array( 'data' => 1 ) )


I will never be the valid forms...

my bugfix: Type.js

function SymfonyComponentValidatorConstraintsType() { .... case 'int': case 'integer': case 'long': // egg bugfix mert number tipusu adat nincs jsben! ezert a === nem mukodik isValid = (value == parseInt(value)); break;

and

fp_js_validator.js function SymfonyComponentValidatorConstraintsType() { ....

    case 'int':
        case 'integer':
        case 'long':
            // egg bugfix mert number tipusu adat nincs jsben! ezert a === nem mukodik
            isValid = (value == parseInt(value));
            break;

why === check is type, but html5 number input value is string!!!

i found intrested post: http://stackoverflow.com/questions/18852244/how-to-get-the-raw-value-an-input-type-number-field

thanks eggp

66Ton99 commented 9 years ago

I do not think this Bundle works with HTML5 validation now, it reimplement it mostly. Integration with HTML5 validation it would be another bit task #75