GithubHelp home page GithubHelp logo

weblineindia / reactjs-url-component Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 307 KB

A ReactJS based URL component provides option to add url (like Instagram url, Facebook url, web url, etc.) with validation. The URL value is automatically validated on blur event. You can even disable url field using disable props.

Home Page: https://www.weblineindia.com/software-development-resources.html

License: MIT License

CSS 3.23% JavaScript 96.77%
reactjs reactjs-components react-components react-libraries reactjs-library reusable-components react-demo reactjs-demo reactjs-url-component url-input url-component react-url reactjs-url instagram-url facebook-url

reactjs-url-component's Introduction

ReactJS - URL Component

A ReactJS based URL component provides option to add url (like Instagram url, Facebook url, web url, etc.) with validation. The URL value is automatically validated on blur event. You can even disable url field using disable props.

Table of contents

Browser Support

Chrome Firefox Safari Edge IE
83.0 ✔ 77.0 ✔ 13.1.1 ✔ 83.0 ✔ 11.9 ✔

Demo

Getting started

Install the npm package:

npm install react-weblineindia-url
#OR
yarn add react-weblineindia-url

Usage

Use the <react-weblineindia-url> component:

import React ,{ Component } from 'react';
import UrlComponent from 'react-weblineindia-url'

class Test extends Component {
  constructor(props) {
    super(props);
    this.state = {
      vData: "",
      isInvalidUrl: false
    };
  }

  onChange(event, isError) {
    this.setState({
      vData: event.target.value,
      isInvalidUrl: isError
    });
  }

  onBlur(event, isError) {
    this.setState({
      isInvalidUrl: isError
    });
  }

  render() {
    return (
      <div>
        <Url
          value={this.state.vData}
          onChange={this.onChange.bind(this)}
          onBlur={this.onBlur.bind(this)}
          placeholder="Enter Url"
        />
        {this.state.isInvalidUrl ? (
          <div className="error-text">
            The URL is not valid
          </div>
        ) : ""}
      </div>
    );
  }
}

export default Test;

Available Props

Prop Type default Description
id String ID for the input
name String Name for the input
value string Value of the component
classname object Class to the input
placeholder String The input field will get this placeholder text
hide Boolean false Hide component
disabled Boolean false Disable component
tabindex Number 0 Tab index of the component
maxlength Number 25 The input maxlength
regex RegExp The input regex
autocomplete String off The input of autocomplelete
type String text Type for the input
urlttpe String 'facebook' Default url type for component 'facebook' you can pass 'instagram','web','linkedin','other'.based on that regex will set.if you pass other you have to pass regex value which you want

Methods

Name Description
onFocus Gets triggered when the autocomplete input field receives focus.
onBlur Gets triggered when the autocomplete input field loses focus.
onChange Gets triggered when the autocomplete results got changed.
onKeypress Gets triggered when a key gets pressed.
onKeyDown Gets triggered when a key gets down.
onKeyUp Gets triggered when a key gets up.

Want to Contribute?

  • Created something awesome, made this code better, added some functionality, or whatever (this is the hardest part).
  • Fork it.
  • Create new branch to contribute your changes.
  • Commit all your changes to your branch.
  • Submit a pull request.

Collection of Components

We have built many other components and free resources for software development in various programming languages. Kindly click here to view our Free Resources for Software Development


Changelog

Detailed changes for each release are documented in CHANGELOG.md.

License

MIT

Keywords

react-weblineindia-url, url-component, react-url-component, react-url-input, reactjs-url, react-url

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.