Coder Social home page Coder Social logo

react-validation's Introduction

react-validation

npm version Build Status Coverage Status dependencies devDependencies

Component to provide simple form validation for React components. It uses the Controlled Components approach for validation.

It is not easy to validate forms with React. The reason is a one-way data flow style. In this case we can't affect forms from the inputs in an easy way. React-validation provides several components which are 'connected' to the form via the input's method attached by the Form component.

It is just a validation and doesn't provide any model or something similar. You can use FormData or something like form-serialize to get form data.

NOTE: Always pass the name props. It's required.

Any additional props (such as event handlers) can also be passed to components.

If you find any bug or error, please feel free to raise an issue. Pull requests are also welcome.

Installation

npm install react-validation

Test

npm test

Example usage

First of all let's define some validations:

import validator from 'validator';
const required = (value) => {
  if (!value.toString().trim().length) {
    // We can return string or jsx as the 'error' prop for the validated Component
    return 'require';
  }
};

const email = (value) => {
  if (!validator.isEmail(value)) {
    return `${value} is not a valid email.`
  }
};

const lt = (value, props) => {
  // get the maxLength from component's props
  if (value.toString().trim().length > props.maxLength) {
    // Return jsx
    return <span className="error">The value exceeded {props.maxLength} symbols.</span>
  }
};

const password = (value, props, components) => {
  // NOTE: Tricky place. The 'value' argument is always current component's value.
  // So in case we're 'changing' let's say 'password' component - we'll compare it's value with 'confirm' value.
  // But if we're changing 'confirm' component - the condition will always be true
  // If we need to always compare own values - replace 'value' with components.password[0].value and make some magic with error rendering.
  if (value !== components['confirm'][0].value) { // components['password'][0].value !== components['confirm'][0].value
    // 'confirm' - name of input
    // components['confirm'] - array of same-name components because of checkboxes and radios
    return <span className="error">Passwords are not equal.</span>
  }
};

That's it. We can now use it in our React components:

import Form from 'react-validation/build/form';
import Input from 'react-validation/build/input';
import React, { Component } from 'react';

export default class Login extends Component {
    render() {
        return <Form>
            <h3>Login</h3>
            <div>
                <label>
                    Email*
                    <Input value='[email protected]' name='email' validations={[required, email]}/>
                </label>
            </div>
            <div>
                <label>
                    Password*
                    <Input type='password' name='password' validations={[required]}/>
                </label>
            </div>
            <div>
                <Button>Submit</Button>
            </div>
        </Form>;
    }
}

Note the validations prop. It's an array of functions which was defined earlier.

Components and props

react-validation provides a components with pre-defined structure and hocs to define it self. The components are: Form, Input, Select, Textarea and Button. All of them are just custom wrappers around the native components. They can accept any valid attributes and a few extra:

  1. isUsed - Input, Select and Textarea: says to react-validation to mark component as it was blured.
  2. isChanged - Input, Select and Textarea: says to react-validation to mark component as it was changed.
  3. validations - Input, Select and Textarea: accepts an array of validations functions.
NOTE: Always provide a name prop to Input, Select and Textarea.

Form component

Form

The most important component, which provides the heart of react-validation. It basically mixes the binding between the form itself and child react-validation components via context. Any valid props can easily be passed to Form, such onSubmit and method.

Form provides four public methods:

  1. validate(name) - validates control(s) with the passed name. The difference between this method and default validation is that validate marks the input as isUsed and isChanged. name - name of the corresponding component(s).

  2. showError(component [,error]) - helps to handle async API errors. component - ref to the React Component to validate. error - error to show. Can be string or jsx.

  3. hideError(component) - hides a corresponding component's error. component - ref to the React Component.

export default class Comment extends Component {
    handleSubmit = (event) => {
        event.preventDefault();

        // Emulate async API call
        setTimeout(() => {
            this.form.showError(this.userInput, <span>API error</span>);
        }, 1000);
    };

    removeApiError = () => {
        this.form.hideError(this.userInput);
    };

    render() {
        return <Form ref={c => { this.form = c }} onSubmit={this.handleSubmit.bind(this)}>
            <div className="row">
                <div className="small-12 columns">
                    <h3>Leave a comment</h3>
                </div>
            </div>
            <div className="row">
                <div className="small-12 medium-4 columns">
                    <label>
                        <Input
                          onFocus={this.removeApiError}
                          ref={c => { this.userInput = c }}
                          placeholder="username"
                          type="text"
                          value="Username"
                          name="username"
                          validations={[required]}
                        />
                    </label>
                </div>
                <div className="small-12 medium-8 columns">
                    <label>
                        <Textarea
                          placeholder="Leave your comment..."
                          value="Comment"
                          name="comment"
                          validations={[required]}
                        />
                    </label>
                </div>
            </div>
            <div className="row">
                <div className="small-12 medium-6 columns">
                    <Button className="button">Submit</Button>
                </div>
            </div>
        </Form>
    }
}

HOCs

react-validations also provides HOC (High Order Component) for each component. That made to have an ability to define own render logic, use mixed props, etc.

import { form, control, button } from 'react-validation';

// Define own Form component
const Form = ({ getValues, validate, showError, hideError, children, ...props }) => ( // destruct non-valid props
  <form {...props}>{children}</form>
);

// Define own Input component
const Input = ({ error, isChanged, isUsed, ...props }) => (
  <div>
    <input {...props} />
    {isChanged && isUsed && error}
  </div>
);

// Define own Button component
const Button = ({ hasErrors, ...props }) => {
  return (
    <button {...props} disabled={hasErrors} />
  );
};

// Now call HOCs on components
const MyValidationForm = form(Form);
const MyValidationInput = control(Input);
const MyValidationButton = button(Button);

That's it. Now MyValidationForm can be used with all given API.

props

form:

getValues - function which returns object with keys by 'name' prop and string values. NOTE: same-name controls will be returned as array of strings. validate(name) - function to validate controls by 'name' argument. It marks control as 'isUsed' and 'isBlured'. showError(component, [,error]) - function to force showing error. component - ref to the control, error - string/jsx. hideError(component) - function to hide error on passed control ref.

control:

error - string or jsx. Note that error will be defined anytime the control has invalid value. Use isUsed and isChanged to apply rendering logic. isChanged - boolean. Indicates the control was changed. isUsed - boolean. Indicates the control was blurd.

button:

hasErrors - boolean. Indicates the whole form contain at least one invalid control.

Input component

Input

A wrapper around the native input. It accepts a validations prop - an array of functions.

<Input name='firstname' validations={[lt8, alpha]}/>

react-validation will break with the first listed rule, if more than one rule is broken. In the example above (lt8 - value length less than 8), for really long value with d1g1t input value, the alpha rule will break validation first. We can control it by ordering rules within the validations array.

Textarea component

Textarea

A wrapper around the native textarea. Like Input, it accepts a validations prop. Nothing special here:

<Textarea name='comment' validations={[required]}/>

Select component

Select

A wrapper around the native select. Like Input, it accepts a validations prop. Nothing special here:

<Select name='city' value='' validations={[required]}>
    <option value=''>Choose your city</option>
    <option value='1'>London</option>
    <option value='2'>Kyiv</option>
    <option value='3'>New York</option>
</Select>

Button component

Button

A wrapper around the native button. React-validation disables (adds disabled prop) the button on error occurrences.

react-validation's People

Contributors

andersdjohnson avatar dbachrach avatar donovanhiland avatar fraziern avatar gektorgrom avatar lesha-spr avatar oleksii-an-jpg avatar worg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-validation's Issues

can't add checkbox input

Common use case for validation: checkbox to agree to Terms of Service. Currently no way to pass checked value to a rule. Consider at least accepting pending #8 so that we can at access the dom element to check the checked property

Meteor doesn't run when Object.assign is used

Hi, thanks for your great library and updates. I have one concern tho, I am using Meteor and I'm trying to apply the Object.assign for extending validations. However, my meteor blows up and logs a very long stack trace. I tried removing the Object.assign and reverting back to .extendErrors and that did well.

Nesting in custom components?

How can I nest <Validation.components.Input /> in a component. When I try to do this I get the following error: TypeError: _this.props._register is not a function.

My code is as following (simplified):

main.js

<Validation.components.Form ref="form" onSubmit={this.handleSubmit.bind(this)}>
  <Input
    name="email"
    type="text"
    value={''}
    validations={['required', 'email']} />

  <Validation.components.Button className="btn btn-primary">Submit</Validation.components.Button>
</Validation.components.Form>

input.js

<div className="form-group">
  <label className="control-label">
  {props.label}

  <Validation.components.Input
    type={props.type}
    className="form-control"
    value={props.value||''}
    name={props.name}
    validations={props.validations} />
  </label>
</div>

forceValidate on disabled button?

Is there a way to run forceValidate upon clicking a currently disabled <Validate.Input> submit button? It appears the onClick is being blocked by the component if button is in disabled state

Thanks

Value does not propagate if wrapped in react-validation Input

Hi Oleksii,

I discovered a strange bug - it seems that in an Input component, once anything is typed in, react-validate prevents from changing the value indirectly (via state or props, i.e. does not work with an alt / redux store for example)

Here's what happens:
git

I produced a minimal example (based on react starter kit), it's all to be seen in components/App/app.js, attached
validation-bug.zip

Could you please have a look?

validateAll()

is validateAll() no more available? Because it is still in the docs. If it is the case, how should I validate all fields? Thanks

Input Wrapper text-area onChange not firing correctly

Hey,

Thanks for the awesome plugin 👍

I needed a text-area with required validation,some thing like this

<Validation.Input ref='description' wrapper="{{ component: 'textarea' }}" className='ui-input form-control' value="{this.props.description}" ref='description' name='description' validations="{[{rule: 'isRequired'}]}" />

But the UI would not reflect the changes based on user input.

I noticed that in Input.jsx file - value attribute is missing under this.props.wrapper condition

` if (this.props.wrapper) {
try {
props = Object.assign({}, this.props.wrapper.props, this.props);

            input = <this.props.wrapper.component ref='element' {...props} className={this.state.className} checked={this.state.checked} onChange={this._handleChange} onBlur={this._handleBlur}/>;
        } catch(e) {
            console.log(e);
        }
    } else {
        input = <input ref='element' {...this.props} className={this.state.className} checked={this.state.checked} value={this.state.value} onChange={this._handleChange} onBlur={this._handleBlur}/>;
    }`

Adding "value={this.state.value}" for wrapper element seems to fix my issue, wanted to check is there a easier way to do the same without modifying your code base.

PS: Using 1.7.4 version

Thanks
Sudarshan

Class error on span

Hi @Lesha-spr ,

In your new version (2.0), rules' errors have changed.

Now we have :
`



`

So when I have the error class, I want the span class to be red. Ok it's easy.
But I already want the input field to have a red border... but in CSS I can't select the input field with this error class.

I've missed some property ?
How to achieve that ?

Thanks.

Meteor - File not found (Components)

Hi, I'm using Meteor and have encountered these errors while building the app.

While building the application:
error: File not found: node_modules/react-validation/src/components/Button.react.jsx
error: File not found: node_modules/react-validation/src/components/Form.react.jsx
error: File not found: node_modules/react-validation/src/components/Input.react.jsx
error: File not found: node_modules/react-validation/src/components/Select.react.jsx
error: File not found: node_modules/react-validation/src/components/Textarea.react.jsx
error: File not found: node_modules/react-validation/src/validation.jsx

Is there any workaround here? Or update in the Readme? thanks

Combo date validation

Hello,

I have a form with some basic input. But I have also a combo date to select the birth date.
I use ComboDate https://github.com/vitalets/combodate to deals with the date and moment.js.

But I don't know how to validate this filed. I want the submit button to be desactivate with validation error.

Have you got any solution to deals with it ?

Thanks.

Unknow prop in console

Hi @Lesha-spr

I have a warning in the console :
Unknow prop for containerClassName, defaultLabelStyle, defaultInputStyle
And
Unknown DOM property inputmode

I've you got a solution ? I'm on 1.7.5.

react validation

Thanks

forceValidate ?

Is there any way to work around the missing forceValidate in v2 ?

I used it in v1 to as I had submit buttons that were not a part of the validation form

FormData returns nothing

In fact I'm not succeeding in getting data from the form in any way on the submit handler.

event.target formdata = null
ref.form.getDOMNode() formdata = null
ref.input.getDomNode() also no available values.

Anyone have any example of a working way to get at form data?

validateAll to return validity?

Sorry to bother with this again, would it be possible for validateAll() method to return true/false to show whether the validations passed or not? Or perhaps an object with non-passed validations as v1.7.5 did?

This is needed when you want to decide on next actions based on the validity. In my case I have a button that upon click checks for all validations within react-validation, as well as some other external things and then submits depending on the outcome

Thanks

Submit button disabled on Chrome

Hi @Lesha-spr

When the login form is filled by Chrome, the submit button is still deactivate. But I i make a click anywhere on the page, the submit button is activated.

Thanks.

null is not an object (evaluating 'child.props')

Hi,

I’ve been stuck on this error for over a day now. When I use react-validation v2, I get this error:

[Error] TypeError: null is not an object (evaluating 'child.props')
[Error] Warning: performUpdateIfNecessary: Unexpected batch number (current 8, pending 3)

And it is pointing to this line:
https://github.com/Lesha-spr/react-validation/blob/master/src/components/Form.react.jsx#L106

I’ve tracked it down to a piece of my code, that dynamically adds/ removes markup based on props, within <Validation.components.Form, e.g.

<Validation.components.Form onSubmit={this.onContinueButtonClick.bind(this)}>
…
…
…
    {this.props.deliveryType != 't' && this.props.deliveryType != 'a' &&
      <div className="row bottom10">
        <div className="col-xs-12">
          <input
            type="checkbox"
            onChange={(e) => { if (!e) return false; this.sameAddressChecbox(e.target.checked); }}
          />
          Same as delivery address
        </div>
      </div>
    }

    {!this.state.billingAddressDisabled &&
      <AddressFinder onAddressSelected={this.addressSelected.bind(this)} />
    }
…
…
…
</Validation.components.Form>

When I remove that bit it doesn’t produce the error anymore. I can't tell whether I'm doing something wrong or whether this is a bug within react-validation. However when I use v1.7.5. with the same code, everything works fine.

Any help please?

Email Validation

Hello,

I need to check if email is already in use for a subcription.
I use Meteor with MongoDB.

I create a rule :
isEmailExist: { className: 'erreur', message: "Already in use", rule: function (value) { Meteor.call('account_creation.checkEmailExist', value, function (error, result) { if (error) { console.log(error) } console.log(result) return !result; }) } }

The call to MongoDB works; result return true ou false if email exist.
But the validation is always false.. the error message is always show.

How can I do that ?

Thanks.

latest validator?

Hi,

Any plans on updating this to work with latest validator (5.2.0 +) ? It doesn't seem to work with it currently, which is a shame, a lot of fixes released since the required 3.41.2

Thank you

Textarea Component

Hi. I am working on a project which needs a textarea component. Is there any extension for it?
Thanks

Unknown prop containerClassName

I have seen a prop containerClassName in the source code in this repo, but whenever I use

<Select name="somename" containerClassName="this" />

It runs, and the div containing the <select> tag contains the 'this' className, but in the console, it says:

Unknown prop 'containerClassName' . . .

Any workaround? Thanks

Unknown props on <input>

Hi, i'm pretty new to React and am trying to use react-validation on a simple input form.
I'm using React 15.2.1 but am getting this error:

Unknown props validations, _registerControl, _unregisterControl, _validate on

Here's my input box:

var InputBox = React.createClass({

onSubmit: function(event) {
    event.preventDefault();
    this.refs.username.showError('Error');
},

render: function() {

  return (
      <Validation.Form onSubmit={this.onSubmit}>
          <Validation.Input
          placeholder="User name"
          ref='username'
          name='username'
          validations={[
            {
              rule: 'isRequired'
            }
          ]} />
          <Validation.Button type='submit' />
      </Validation.Form>
  );
}

});

Any help would be appreciated!

can u hidden error dom when valid?

Validation.Input runs before Validation.extendErrors(), so defaultHintClassName: 'ui-hint',
defaultContainerClassName: '' cannot extend by Validation.extendErrors()

Indicate requirement of validation props in the documentation

This is rather an enhancement. I've noticed that not providing the validations prop in an Input component causes the console to produce an error.

this.props._register is not a function

I suggest that an improvement on the documentation be made, just a minor fix tho. 👍

Revalidates everything on every change when using alt store

Hi,

I'm using flux (alt) stores in tandem with react-validation. However it seems that every change in ANY input (and thus data in the store) forces validation on ALL fields with react-validation. This of course makes all the fields invalid, without the user even trying to fill them in. I suspect this has something to do with isUsed in the component state?

I've been trying to find a solution to this for some time now, unsuccessfully. Any pointers/ideas please?

Thank you

Below my code

import React, { PropTypes, Component } from 'react';
import BookingStore from '../../stores/BookingStore';
import connectToStores from 'alt-utils/lib/connectToStores';
import BookingActions from '../../actions/BookingActions';
import Validation from 'react-validation';
import validator from 'validator';

@connectToStores
class TestT extends Component {

    static getStores() {
        return [BookingStore];
    }

    static getPropsFromStores() {
        return BookingStore.getState();
    }

    render() {
        return (
            <Validation.Form>

                First name:
                <Validation.Input
                    type="text"
                    name="fname"
                    value={this.props.firstName}
                    onChange={(e) => { if (!e) return false; BookingActions.updateFirstName(e.target.value); }}
                    validations={[{ rule: 'isAlpha' }]}
                />

                Last name:
                <Validation.Input
                    type="text"
                    name="lname"
                    value={this.props.lastName}
                    onChange={(e) => { if (!e) return false; BookingActions.updateLastName(e.target.value); }}
                    validations={[{ rule: 'isAlpha' }]}
                />

            </Validation.Form>
        );
    }

}

export default TestT;

Binding to state

Using version 1.6.7. still having issues with this. When I use react-validation can not get "this.refs.username.value" in the submit function or bind to state.

showError behavior with other input

Hi @Lesha-spr,

Thanks for your the 2.0 version :)

I use the showError function to show error with an asynchronous function. It's work very well.
But, when I have other input, and I focus to it, the show error of the asynchronous rule disappear.
I think your clear all errors onBlur function.

I've you got an idea to avoid that ?
Do you need an example ?

Thanks.
Remy.

import Validation from 'react-validation' does not work

The new version 2.0.1. does not export Validation class, and as such cannot be used by

import Validation from 'react-validation'

as per documentation, but would rather have to be

import { Button } from 'react-validation'

etc.

Is this intended behaviour (and docs need updating) or an error?

The 1.7.5 version worked like this since it had
module.exports = Validation;

Support for other fields

It would be great to see support for text areas.

Also support for react-maskedinput would make this lib excellent.

I may take a stab at it and submit a PR. Btw, thanks for this straightforward validation solution. I've tried a few others, and this one makes the most sense. It's a shame there are so few stars.

Possible to compare fields?

Is it possible to validate fields with eachother, specifically I want to validate that password and passwordConfirmation fields match.

Thanks!
Ash

Custom onClick

Hello! I would love a way to use your Validation library with a button that is not the submit button. I currently have an email form with a+ Validation.Button to add a valid email to my React component state, and a Share button to send emails to the addresses stored in state when not empty. I would love to be able to disable my Share button with the same constraints as my + button plus a customized rule.

The problem is that I need the Share button to not be a "submit" button, and have it instead trigger a sendShareEmail() function. I'm currently working around it using a generic button and manually disabling it based on certain conditions, but I would rather stay consistent and use your library to disable both buttons and reduce repetition. An onClick prop for the Validation.Button would be a great addition. Thanks so much!

Does not validates input in child component with ES6

I am new to react js and I am not able to add validation for child components. I have a main component and within that component I have <Validation.Form>.

<Validation.Form className='createGroupForm clearfix' id='createGroupForm'> <Validation.Input ref='username' name='username' validations={[{rule: 'isEmail'}]} /> <ListItemWrapper items={this.state.items} /> </Validation.Form>

In ListItemWrapper I have an input where I have to add validation but _validate and _registeredControl are noting getting bound to the input.

Add custom HTML nodes inside containerClass props

Hi. This is a suggestion for those who use MaterializeCSS framework and some other CSS frameworks out there.

I am trying to append an h6 label to my Input component., but it messes up because the h6 turns out to be outside the container of the Input. An example would be:

<div className="row">
              <h6>Date</h6>
              <Input autoComplete="off"
                     type="text"
                     className=""
                     containerClassName="input-field col s6"
                     value=""
                     placeholder="Weight (in cm)"
                     validations={['required']}
              />
</div>

Expected Result:

Date
_____________ -> Input component

Actual:

Date
    _____________ -> Input component

When I traced the code, transferring the h6 inside the container solves the problem.

UPDATE: Removing the containerClassName and creating a main wrapper for the components solves the problem, however adding this suggestion may increase flexibility for some UI frameworks, especially when icons beside textboxes are an option

How to use with Babel 6 ?

Seems that the usage suggested in documentation doesn't work with new Babel 6 and produces this error:
Property object of JSXMemberExpression expected node to be of a type ["JSXMemberExpression","JSXIdentifier"] but instead got "MemberExpression"

I'm guessing it is due to this: https://phabricator.babeljs.io/T6662

screen shot 2016-09-05 at 15 19 37

I'm trying to figure out how to use react-validation with the suggested fix, but didn't have much luck.

Uncaught TypeError: error.includes is not a function

I have the following form set up:

<Validation.components.Form ref={c => this.form = c} onSubmit={this.handleSubmit.bind(this)}>
  <Validation.components.Input value="" name="my_input" validations={['required']}/>
  <button type="submit">Submit</button>
</Validation.components.Form>

My onSubmit function:

handleSubmit(event) {
  event.preventDefault();
  this.form.showError('my_input', 'Error');
}

My rules:

Object.assign(Validation.rules, {
  required: {
    rule: (value) => {
      return value.trim();
    }
});

When I submit the form, I get the following error in the console, regardless of whether or not my input is valid:

index.js:2308 Uncaught TypeError: error.includes is not a function

When I examine the error variable at index.js:2308, it gives me the following:

Object {0: "E", 1: "r", 2: "r", 3: "o", 4: "r", force: true}

How can I get this basic functionality to work?

File Support

Hello again.
Is there any extension for files in react-validation?
Validation.Input type=fileworks well, but when I use it with form-serialize, it does not "capture" the value of the file itself, so I thought there may be an extension for this one.

Thanks in advance.

Got an error in IE10

Hi there, when I test browser supports, I found out that in IE10, this error will cause script crashes:

 value: function _register(component) {
                this.components[component.props.name] = component;
 }

Unable to get property 'name' of undefined or null reference

I notice in the following code block:

var Input = function (_Component) {
        (0, _inherits3.default)(Input, _Component);

        function Input(props, context) {
            (0, _classCallCheck3.default)(this, Input);

            var _this = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(Input).call(this, props, context));
            context._register(_this);
            return _this;
        }

In IE10, '_this' returns

image

While in Chrome, Firefox, IE11, '_this' returns

image

@Lesha-spr I really like this plugin you made, but IE10 support is required for me. Please take a look at it. Thanks.

I keep getting th "Uncaught TypeError: This library (validator.js) validates strings only" error.

I get this error, it´s from the function:
exports.default = assertString; function assertString(input) { if (typeof input !== 'string') { throw new TypeError('This library (validator.js) validates strings only'); } } from the app.js file.

I was trying to put a variable in the input validation. But even when all changes deleted I still get the "Uncaught TypeError: This library (validator.js) validates strings only" error. While before everything worked fine.

Edit: The error disappeared, Don´t know why or what I did, but it´s gone now.

Kind regards,
Didi Willems

Disable / Enable button

Hi, i'm using this for URL validation on a input and it's all working fine..

One thing though. My app does an api lookup using the URL from an input box, so after the URL input is validated the submit button is enabled .. but...

I need to, after onSubmit, disable the button so a user can't do the api look up twice/while the look up is happening.

I will also then need to re-enable the button after the ajax response is returned.

Any ideas how i can do this?

Could there be any support for defaultValue?

Hi, this may be unusual for react components, but I would like to ask if there could any support for defaultValue for react-validation? Like

if(this.props.defaultValue)
return the input
else
return the input with onchange

Is this one possible?

I asked because I am using this amazing library together with Google Maps API , and I am encountering some errors when a defaultValue is not supplied to the input. I end up using the standard input element. Thanks in advance

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.