JavaScript in multiple files

Posted by vijay.shad on Stack Overflow See other posts from Stack Overflow or by vijay.shad
Published on 2010-03-13T17:13:55Z Indexed on 2010/03/13 17:15 UTC
Read the original article Hit count: 270

Filed under:

Hi,

I Have created two JavaScript files.One file is "validators.js" and other is "UserValidations.js".

Here is the code for validators.js

function isBlankString(value) {
    if (value.replace(/\s/g, "") == "") {
        return true;

    } else {
        return false;
    }
}

In other js file I have defined function for validating user name like this.

function validateUsername(element) {

    var username = element.value;

    if(value.replace(/\s/g, "") == ""){
        //nothing to validate
        return;
    }else{
        //validation logic
    }

}

Now as it is obvious i should have used isBlankString(value) method to check string length. But I am clue less about how can i use the function defined in other file?

© Stack Overflow or respective owner

Related posts about JavaScript