Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Character Counter in Text Box successfully #3765

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ <h2>Have a play.</h2>
<a href="#" class="btn btn-primary download-pdf">Download PDF</a>
</div>

<div id="charCount" style="margin-top: 10px; font-size: 0.9rem;">Characters typed: 0</div>


<label class="checkbox-inline">
<input type="checkbox" id="auto-refresh" checked="checked"> Auto refresh on changes?
</label>
Expand Down Expand Up @@ -102,5 +105,31 @@ <h2>Have a play.</h2>
<!-- Scripts in development mode -->
<script type="text/javascript" src="./examples/js/pdfobject.min.js"></script>
<script type="text/javascript" src="./examples/js/editor.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.14/ace.js"></script>

<script type="text/javascript">
// Initialize Ace Editor
var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/javascript");

// Function to update character count
function updateCharCount() {

var text = editor.getValue();

var charCount = text.length;

document.getElementById('charCount').textContent = "Characters typed: " + charCount;
}

editor.getSession().on('change', updateCharCount);

window.onload = function() {
updateCharCount();
};
</script>

</body>
</html>
Loading
Loading