Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation fail on multiple number input #418

Closed
rpallares opened this issue Jan 20, 2017 · 14 comments
Closed

Validation fail on multiple number input #418

rpallares opened this issue Jan 20, 2017 · 14 comments
Labels
bug Identified bug which needs a fix
Milestone

Comments

@rpallares
Copy link

Description

If a filter of type number or double is defined, the "in" operator never validate the value if multiple values are defined

Step to reproduce

  • Create a filter as type equal 'double' or 'integer'
  • Define a value separator (| in my case to not conflict with double commas)
  • Launch the query builder
  • add the filter and set "in" operator with value "3.5|3.2"
  • Observe that the value is never validated

##Supposed cause
Function QueryBuilder.prototype.validateValueInternal only verify if there is multiple values on select and radio filters

@rpallares
Copy link
Author

I'll try to implement that feature just by setting valueGetter and valueSetter and a validation.format regexp as workaroud.
But the best probably should be to re-write the QueryBuilder.prototype.validateValueInternal

Nice component in any cases :)

@mistic100
Copy link
Owner

mistic100 commented Jan 20, 2017

Ok a really had an hard time understanding the problem (sorry for the previous deleted messages).

I'll investigate this, type: 'integer' with input: 'text' and a value_separator should work

@mistic100 mistic100 added the bug Identified bug which needs a fix label Jan 20, 2017
@mistic100
Copy link
Owner

mistic100 commented Jan 22, 2017

After some research I guess you are not using Chrome or you are using a custom 'input' function, because in Chrome, because QueryBuilder uses type="number" you cannot even enter a pipe in the input.

So what I did is to add a new input type number which is the default for integer and double types, but if the user explicitly sets type: 'integer', input: 'text it will uses a real text input.

Now the validation is still not working...

@mistic100
Copy link
Owner

mistic100 commented Jan 22, 2017

@mistic100 mistic100 added this to the 2.4.1 milestone Jan 22, 2017
@rpallares
Copy link
Author

OK, it's working perfectly :)
I had some difficulties to build the dev version due to the new jQuery.extendext dependency that is not yet documented.

Indeed, I don't use Chrome, I prefer Firefox which is open, although less well on some rare aspects. It don't prevent typing pipes into number inputs.

Thank you for your very quick fix, that feature will be very useful for my project.

@mistic100
Copy link
Owner

what do you mean "not documented" ? it's in dependency in the bower/package file and in the readme

@officiallysameer
Copy link

Hi Mistic,
The value separator works for strings but not for numbers (even when i specify the input type as text . I cannot get it to display the text type input.
Wonder what i am doing wrong. Here is a jFiddle example
https://jsfiddle.net/z7dem1mg/

I tried to manually override this by replacing QueryBuilder.types[filter.type] in the following snippet with
filter.input, i get the text input, but i get validation errors when i try to use value_separator

switch (QueryBuilder.types[filter.type]) {
                   case 'number':
                       h+= '<input class="form-control" type="number" name="' + name + '"';
                       if (validation.step !== undefined) h+= ' step="' + validation.step + '"';
                       if (validation.min !== undefined) h+= ' min="' + validation.min + '"';
                       if (validation.max !== undefined) h+= ' max="' + validation.max + '"';
                       if (filter.placeholder) h+= ' placeholder="' + filter.placeholder + '"';
                       if (filter.size) h+= ' size="' + filter.size + '"';
                       h+= '>';
                       break;

                   default:
                       h+= '<input class="form-control" type="text" name="' + name + '"';
                       if (filter.placeholder) h+= ' placeholder="' + filter.placeholder + '"';
                       if (filter.type === 'string' && validation.min !== undefined) h+= ' minlength="' + validation.min + '"';
                       if (filter.type === 'string' && validation.max !== undefined) h+= ' maxlength="' + validation.max + '"';
                       if (filter.size) h+= ' size="' + filter.size + '"';
                       h+= '>';
               }

@mistic100
Copy link
Owner

did you really build on dev branch and not on master ?

@officiallysameer
Copy link

i was pulling the contents from cdn earlier (jsdeliver), but wanted to look at the code so copied the standalone from the dev branch to try manually override

@officiallysameer
Copy link

i think i have not built on dev branch. Will try it now

@rpallares
Copy link
Author

Oops, yes the jQuery.extendext is documented. I'm just tired on monday I guess.

@officiallysameer
Copy link

Hi Mistic,
Tried after rebuilding from dev. It worked.
Thanks man. You rock

@mistic100 mistic100 modified the milestones: 2.4.2, 2.4.1 Feb 12, 2017
@naveendb92
Copy link

@officiallysameer can you post a jsfiddle, support for multiple values for IN operator of type integer? I'm unable to get this done

@officiallysameer
Copy link

officiallysameer commented Jan 30, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Identified bug which needs a fix
Projects
None yet
Development

No branches or pull requests

4 participants