npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ovld

v1.0.12

Published

ovld unobtrusive client validation for asp.net core mvc

Readme

ovld unobtrusive validation

npm version

Unobtrusive client validation for asp.net core mvc (can be used instead of jquery.validate + jquery.validate.unobtrusive)

Installation

Add the scripts to your page:

<script src="~/lib/ovld/ovld.js"></script>
<script src="~/lib/ovld/ovld.unobtrusive.js"></script>

Manually call unobtrusive validation

On page load all form tags will be bound to automatically, but you can also call the bind manually, for example:

ovld.unobtrusive.bind();

Turn off automatic bind on page load

ovld.unobtrusive.setDefaults({ autorun: false });

Add additional client rules

Besides the validation rules parsed from the unobtrusive html attributes, we can add additional validation rules:

// turn off automatic binding
ovld.unobtrusive.setDefaults({ autorun: false });`

// bind manually 
const boundApi = ovld.unobtrusive.bind({
      selector: 'form',
      { Name: [{chk: noAsdf, msg:'Name can\'t contain asdf'}] }
  });

// rule: value can't contain 'asdf' string
function noAsdf({v}) {
    return v.indexOf('asdf') !== -1;
}

Unbind client validation

const boundApi = ovld.unobtrusive.bind({...});

// call destroy later if necessary
boundApi.destroy();

Related editors

We can make certain editors related, so that when we change the value of one the other is also checked, e.g. Password and ConfirmPassword, example:

const boundApi = ovld.unobtrusive.bind({
        selector: '#f1 form',
        rules,

        // when checking `Name`, rules of `Name1` will also be checked
        // when checking NumA, rules of NumC will also be checked
        related: {
            "Name": ["Name1"],
            "NumA": ["NumC"],
            "NumB": ["NumC"],
        }
    });

// value must equal the editor with name=Name
function sameAsName({v, input }) {
    let nameVal = find(input.closest('form'), '[name=Name]')[0].value;
    return v != nameVal;
}

// value must be equal to editor with name=NumA + name=NumB
function sumOfNumbers({v, input}){
    const form = input.closest('form');
    const numA = parseInt(find(form, '[name=NumA]')[0].value, 10);
    const numB = parseInt(find(form, '[name=NumB]')[0].value, 10);

    if (parseInt(v, 10) !== numA + numB){
        return {
            msg: `${numA} + ${numB} != ${v}`
        };
    }
}

CustomRules

see custom rules page for example

Using ovld directly without unobtrusive attributes

ovld.bind({
  subev: 'submit', // submit event, a custom event can be used
  selector: '#mydiv',
  //cont: myElm // alternative to selector
  rules:{
    'Name': [
              { chk:ovld.rules.req, msg:'The Name field is required.' },
              { chk: ovld.rules.len({ max: 50, min: 3 }), msg: 'Length must be between 3 and 50' }
           ],
    'Date': [{ chk: ovld.rules.req, msg: 'The Date field is required.' }, ],
  },

  // container relative to the input where to put or clear the validation message
  msgCont: function(o) {
            return o.input.closest('.awe-row').querySelector('[vld-for=' + o.name + ']');            
        }
});

Ignore certain editors

Example, ignore editors whose name starts with 'abc' (add this script after you've referenced ovld.js)

ovld.ignore = function(input){
    if(input.getAttribute('name').startsWith('abc')){
        return true;
    }
}

Live example here: https://demo.aspnetawesome.com/Unobtrusive (also reason this was created)

ovld.js used directly (without unobtrusive) for client validation of inline editing grid rows: https://demo.aspnetawesome.com/GridInlineClientValidation