-1

I have a ASP.NET textbox. On text change or move to a different control in the page, I want to check if textbox value ends with .zip, if not show a text message that .zip extension text is required. I have tried the below, but not sure how to get the ends with .zip and show message.

  $('#<%=txtfilename.ClientID%>').change(function (e) {

            var value = $(this).val();                 
        });
venkat14
  • 583
  • 3
  • 12
  • 34
  • right click and inspect the textbox in your browset to get its Id or class name, then you this to check text change or compare text in your js – user3563774 Feb 13 '19 at 06:53
  • Possible duplicate of [JavaScript or jQuery string ends with utility function](https://stackoverflow.com/questions/1095201/javascript-or-jquery-string-ends-with-utility-function) – Michael Feb 13 '19 at 07:46

1 Answers1

0

You could try regex. Something like this might meet your need:

  if(value.match(/.zip$/i)) {
    $('#warningMessage').show();
  } else {
    $('#warningMessage').hide();
  }
Michael
  • 1,028
  • 18
  • 25