Quantcast
Channel: StuntCoders » jQuery
Viewing all articles
Browse latest Browse all 10

jQuery substring

$
0
0

Substring is a JavaScript function which can be useful combining with jQuery. It is possible – very often that you will need limit for number of characters that user can enter in textarea in order to fill in some form. Using this simple snippet, you will be able to do so.

1
2
3
4
5
6
7
jQuery('#textArea').keypress(function() {
	var text = jQuery('#textArea').val();
	if(text.length > 400) {
		text = text.substring(0, 400);
		jQuery('#textArea').val(text);
	}
});

Example of jQuery substring

Please enter maximum of 100 characters:


Viewing all articles
Browse latest Browse all 10

Trending Articles