0

I am using Javascript and its prototype feature to call the function and wrote the following piece of code.

function validateInteger(value) {

    console.log(value);

    if (value == '' || value == null){
        return null;
    }

}

function isValidInteger(obj) {
    console.log(obj);
    isValidInteger.prototype.validate = validateInteger;
}

So here I want to know, how can I pass this obj param to validateInteger. and validateInteger must also accept its value on form submit.

Could some one help me on this?

Thanks

keepmoving
  • 1,813
  • 8
  • 34
  • 74
  • 1
    can you show us how these functions are going to be used? it is not very clear what you are trying to achieve here.. is `isValidInteger` a global variable used in the `isValidInteger` function, or the function itself? is the prototype `validate` meant to be a function to be used, or does it store the result of `validateInteger` with `obj` as parameter? – Kaddath Aug 22 '17 at 16:30
  • 1
    [Don't assign to prototype properties from inside the constructor](https://stackoverflow.com/questions/28255957/assigning-prototype-methods-inside-the-constructor-function-why-not)! – Bergi Aug 22 '17 at 16:38
  • 1
    It's totally unclear what you are trying to do, and why you would want to use prototype inheritance here. Do you even need an object at all? Do you know how methods work in JS? – Bergi Aug 22 '17 at 16:40
  • Thanks for all your help. I resolved this problem with some other approach. – keepmoving Aug 31 '17 at 01:59

0 Answers0