Tuesday, June 1, 2021

Slip 9. Write a jQuery code to allow the user to enter only 15 characters into the textbox.

 

9. Write a jQuery code to allow the user to enter only 15 characters into the textbox. 

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  
  <title>Limit character input in the textarea including count</title>
 <style type="text/css">
  textarea {
       display:block;
       margin:1em 0;
 }  
</style>  
 
 <script>
     $(document).ready(function(){
    $('textarea').keyup(function() {
    var maxLength = 15;
    var textlen =  $('textarea').val().length;
    var remtextlen= maxLength-textlen
    $('#remchars').html(remtextlen);
});
});
 </script>
  </head>
 <body>
<form>
<label>Maximum 15 characters</label>
 
  <textarea id="textarea" maxlength="15"></textarea>
  <span id="remchars">15</span> Character(s) Remaining
 </form>
</body>
</html>

// OutPut




1 comment:

Slip 10. Write a jQuery code to make first word of each statement to bold.

  Slip 10. Write a jQuery code to make first word of each statement to bold.  <!DOCTYPE html> <html>   <head>     <scri...