Giter Club home page Giter Club logo

Comments (12)

orefalo avatar orefalo commented on August 26, 2024

I don't get the feature u r trying to implement.

It's either

  • user needs to fill field1 or field2
    OR
    user needs to fill field1 and field2

I also don't understand why the require check is an issue, please provide more details

from jquery-validation-engine.

harobed avatar harobed commented on August 26, 2024

Example 1 :

  • field1 : ""
  • field2 : ""

=> fail

Example 2 :

  • field1 : "foobar"
  • field2 : ""

=> success

Example 3 :

  • field1 : ""
  • field2 : "foobar"

=> success

Example 4 :

  • field1 : "foobar"
  • field2 : "foobar"

=> success

Same thing with 3, 4… fields.

This is a better example ?

from jquery-validation-engine.

orefalo avatar orefalo commented on August 26, 2024

Yes much better,

There is a sample called demoValidators.html which does a validation using a function.
You will need to define the validation rule on both of your fields, as such
class="validate[required,funcCall[checkFields]]"

then, create the method itself

   function checkFields(field, rules, i, options){
            // change this logic for your specific needs
             if (field.val() != "HELLO") {
                // this allows to use i18 for the error msgs
                return options.allrules.validate2fields.alertText;
            }
      }

Note that in the function, you are free to add jquery lookups to find your fields. such as

     jQuery("#myID"));

Hope this helps,

from jquery-validation-engine.

harobed avatar harobed commented on August 26, 2024

Your solution don't work, I've already tested.

in my fields, I put class="validate[funcCall[myfunc]]"

not "required" because all fields are not required.

Next if "myfunc" function return a string, option.isError is disable because there are

if(!required){
    if(field.val() == "") options.isError = false;
}

in "_validateField" method.

You can do the test, your solution don't work.

Regards,
Stephane

from jquery-validation-engine.

orefalo avatar orefalo commented on August 26, 2024

ok I got it, try with "optional" instead of "required"

from jquery-validation-engine.

harobed avatar harobed commented on August 26, 2024

I didn't see "optional" option in source code, documentation or example.

It's new feature ?

from jquery-validation-engine.

orefalo avatar orefalo commented on August 26, 2024

you are right, it has been removed in 2.0

Could you plz send me a sample ?

from jquery-validation-engine.

harobed avatar harobed commented on August 26, 2024

You can download this example :
http://dl.stephane-klein.info/jQuery-Validation-Engine/demoValidators.html

At the bottom of page, there are "At least one field is required" fieldset.

from jquery-validation-engine.

harobed avatar harobed commented on August 26, 2024

I did a pull request to fix this request.

from jquery-validation-engine.

bartclaeys avatar bartclaeys commented on August 26, 2024

I'm having the same issue, is it still unresolved?

from jquery-validation-engine.

orefalo avatar orefalo commented on August 26, 2024

pull request has been merged, issue is resolved -> Closed status

from jquery-validation-engine.

harobed avatar harobed commented on August 26, 2024

Great :)

from jquery-validation-engine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.