I'm working on a custom rule (jQuery Validation Plugin), which it checks the first & last letter of string (input).
Rule : User can not enter . or _ at first or end of the input.
I have written a function with my pure javascript knowledge. I don't know how to use the function in this jQuery plugin !
My code :
    var text = document.getElementById('UserName').value;
    var firstChar = text.slice(0, 1);
    var lastChar = text.slice(-1);
    function validUser() {
        if (firstChar === '.' || firstChar === '_' || lastChar === '.' || lastChar === '_') {
            return true;
        } else {
            return false;
        }
    }
I have seen this link : https://jqueryvalidation.org/jQuery.validator.addMethod/
But still I don't know how can I use my own code.
 
     
    