Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mathewparet/form-error-control

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mathewparet/form-error-control

A form control mechanism to handle forms and errors returned by laravel and disable controls or show errors accordingly

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

@mathewparet/form-error-control

A js form and error class to easily handle errors returned by Laravel. Attach input controls to the form object to see magic!

Installation

npm i @mathewparet/form-error-control

Usage

import Form from "@mathewparet/form-error-control";
registrationForm = new Form({
    name: null,
    email: null,
    password: null,
    password_confirmation: null,
});
// use this form varible as model holder for form controls

Submitting form

To submit form using this form module, just call <form-object>.<method>(<url>). This returs a promise. Before the promise then or catch is called the form.errors object will be populated with any errors returned by Laravel.

Example:

function submitForm(e)
{
    e.preventDefault();
    this.registrationForm.post('/api/register')
        .then(response => console.log(response))
        .catch(error => console.log(error));
}

Automatically clear errors when fields are updated

To automatically clear form error variables when fields are updated, assign a callback to the keyDown event of the form:

function formKeyDownEvent($event)
{
    registrationForm.errors.clear($event.target.name);
}

Get error message for a form item

registrationForm.errors.get('name');

Check whether a form item has any error

registrationForm.errors.has('name');

Additional properties

<form-object>.busy will be set to true when the form has been submitted, but no response (success or error) has been returned yet.

FAQs

Package last updated on 19 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc