Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
simplevalidate
Advanced tools
Readme
Simple form validation that also exposes your user's shortcomings :D
npm install simplevalidate
or just include the appropriate scripts.
Simple: pass in a form element into Validate()
. It will loop through all inputs and selects and returns a promise. If there's an error, then it will return the names of the inputs as an array; otherwise it will return the form data as an object.
If there's an error it will return an object like so: try it yourself, console log the errors!
{
names: ["error-input-name1", "error-input-name2"],
inputs: [inputDomNode, inputDomNode]
}
<!-- You can specify the following with data attributes:
data-minlength -> minimum number of characters
data-maxlength -> maximum number of characters
data-name -> The label/name of the error, otherwise [name] will be used
required -> if omitted, ignore field validation
NOTE:
add `novalidate` to form to disable native html5 validation
-->
<fieldset>
<label>Some input label</label>
<input type="text" name="input" data-name="Some input" data-minlength="5" data-maxlength="15">
</fieldset>
const form = document.querySelector('form');
const submit = form.querySelector('button');
const errors = form.querySelector('.errors');
submit.addEventListener('click', function(event) {
event.preventDefault();
Validate(form)
.then((data) => {
// VALID! Do stuff here like...
// AJAX away the data, etc.
fetch(url, {
method: 'POST',
body: JSON.stringify(data)
});
})
.catch((errors) => {
// INVALID! You get back an object with arrays of
// invalud input names and elems
for (const input of errors.inputs) {
input.classList.add('is-error');
// add some class to the parent <fieldset>
input.parentElement.classList.add('whoa-this-input-got-an-error');
}
document.querySelector('errorMsg').innerHTML = errors.names.join(', ');
});
});
FAQs
Simple and minimal form validation
The npm package simplevalidate receives a total of 0 weekly downloads. As such, simplevalidate popularity was classified as not popular.
We found that simplevalidate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.