Giter VIP home page Giter VIP logo

react-form-input-validation's People

Contributors

gitter-badger avatar gokulakannant avatar

Stargazers

 avatar  avatar  avatar  avatar

react-form-input-validation's Issues

How to validate confirm password?

In documentation says:

confirmed
The field under validation must have a matching field of foo_confirmation. For example, if the field under validation is password, a matching password_confirmation field must be present in the input.

Code:
this.form.useRules({ first_name: "required", last_name: "required", email: "required|email", password: "required|passwordchk|confirmed" });

Form:
<input type="password" className={this.state.errors.password ? "form-control is-invalid" : "form-control"} name="password" id="password" placeholder="Create password" onBlur={this.form.handleBlurEvent} onChange={this.form.handleChangeEvent} value={this.state.fields.password} noValidate /> <input type="password" className={this.state.errors.password_confirmation ? "form-control is-invalid" : "form-control"} name="password_confirmation" id="password_confirmation" placeholder="Confirm password" onBlur={this.form.handleBlurEvent} onChange={this.form.handleChangeEvent} value={this.state.fields.password_confirmation} noValidate />

Output:

errors
{password: "The password confirmation does not matc…}
password
"The password confirmation does not match."

fields
{email: "", first_name: "", last_name: "", password…}
email
""
first_name
""
last_name
""
password
"Pass@123."
password_confirmation
"Pass@123."
isValidatorUpdate
true

Error: Validator `` is not defined!

Hi

I have field password and not required, like that
image

If I not enter this field, it's working, but if I enter this field, it show error
image
When input text and when submit form.

Please help me!
Thanks

How to use confirmed rule?

Hi,

I've been trying to use the rule confirmed for a long time but i couldn't do it, please explain how to use it, and why is it not like the rule 'different:attribute'?
This is my code:

this.form.useRules({
        email: "required|email",
        password: "required|custom_password_rule",
        password_confirmation: "confirmed",
});

Now how to link password with password_confirmation, shall i do it in the html code? how?

Thanks!

Unable to validate dynamically added array of fields with it?

I have created a couple of fields all same.
`
//This is the code inside of my render return
this.state.fields.features.map((feature, index) => {
if (index != 0) {
return (

-

<Input type="text" onChange={(e) => this.handleChangeOfFeature(e, index)} className="float-left ml-1" name="features[]" value={feature} placeholder="feature" onBlur={this.form.handleBlurEvent}
onChange={this.form.handleChangeEvent} />

<Button type="button" color="primary" onClick={() => { this.addFeature("") }}>+


{console.log(this.state.errors.features)}
{/* {this.state.errors.features[index] ? this.state.errors.features[index] : ""} /}

)
} else {
return (
<Input type="text" onChange={(e) => this.handleChangeOfFeature(e, index)} className="float-left ml-1" name="features[]" value={feature} placeholder="feature" onBlur={this.form.handleBlurEvent}
onChange={this.form.handleChangeEvent} />

<Button type="button" color="primary" onClick={() => { this.addFeature("") }}>+


{console.log(this.state.errors.features)}
{/
{this.state.errors.features[index] ? this.state.errors.features[index] : ""} */}

)
}
})

//This is add same field
addFeature(value) {
let fields = this.state.fields;
fields["features"] = [...this.state.fields.features, value];
this.setState({
fields
});
}

This is what's inside my constructor method
this.state = {
fields: {
avatar: "",
features: []
},
errors: {
},
}
this.form = new ReactFormInputValidation(this);
this.form.useRules({
features: "required|array",
});
this.form.onformsubmit = (fields) => {

}
`
The problem is it's ok with empty strings. Laravel had rule to even validate inside of the array like.
array.*:"required"
How can i make it not ok with empty strings inside of array.

How to use with radios and checkboxes?

Hi, how would you use this with radios and checkboxes, it's kind of confusing and I can't seem to get this to work for radios and checkboxes. I'm trying to get the check box to work for accepting "Terms of Service" for example, but the "accepted" rule doesn't seem to work.

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.