Created
November 7, 2011 01:42
-
-
Save niczak/1343979 to your computer and use it in GitHub Desktop.
Check field length, replace text and alert user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
// bind function to event | |
$("#description").keyup(function() | |
{ | |
// store value | |
var description = $("#description").val(); | |
// check length | |
if(description.length > 244) | |
{ | |
// grab substr | |
var replace = description.substr(0,244); | |
// replace value | |
$("#description").val(replace); | |
// alert user | |
alert("Maximum length for description reached."); | |
// return yo | |
return; | |
} | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment