How to count words in a string using JavaScript function? Example

<!DOCTYPE html>
<html>
<body>
    <input type="file" id="myFile" onchange="myFunction()">
    <script>
        function myFunction() {
            debugger
            var x = document.getElementById("myFile");
            var spiltFilename = x.files[0].name.split('.');
            var countFilenameChar = spiltFilename[0].length;
            if (countFilenameChar >= 2)
                alert("Filename should not exceed 200 characters");
        }
    </script>
</body>
</html>

Share:

No comments:

Post a Comment

Thursday, 21 November 2019

How to count words in a string using JavaScript function? Example

<!DOCTYPE html>
<html>
<body>
    <input type="file" id="myFile" onchange="myFunction()">
    <script>
        function myFunction() {
            debugger
            var x = document.getElementById("myFile");
            var spiltFilename = x.files[0].name.split('.');
            var countFilenameChar = spiltFilename[0].length;
            if (countFilenameChar >= 2)
                alert("Filename should not exceed 200 characters");
        }
    </script>
</body>
</html>

No comments:

Post a Comment

Popular

Total Pageviews

Archive