FilterTextBoxExtender in AJAX enables the input of carriage returns

I need assistance with a multi-line text box that I'm using an AJAX FilteredTextBoxExtender on to restrict user input to just numbers. However, I also want users to be able to add a new line by pressing the enter key. I've looked around for a solution but haven't been successful. Does anyone have any ideas on how to achieve this?

Thank you in advance!

Below is the code snippet I am referring to:

<asp:TextBox ID="txtEIDEntryBox" runat="server" CssClass="PrettyEntryBox" TextMode="MultiLine" Height="300px" Width="100px"></asp:TextBox>
    <ajaxToolkit:FilteredTextBoxExtender ID="ftbeEID"
            runat="server"
            TargetControlID="txtEIDEntryBox"
            FilterType="Custom" ValidChars="0123456789"></ajaxToolkit:FilteredTextBoxExtender> 

Answer №1

To enhance the FilterType, insert Custom and then incorporate the following code in the back-end:

Protected Sub filter_IdentifierFilter_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles filter_IdentifierFilter.Init
    filter_IdentifierFilter.ValidChars = filter_IdentifierFilter.ValidChars & vbCrLf
End Sub

found at

Answer №2

Unfortunately, it doesn't appear to be achievable using the current setup. A possible solution could involve implementing jQuery instead. You can find a helpful response here.

$.fn.filterTextBox = function() {
            return this.each(function() {
                $(this).keydown(function(e) {
                    var key = e.charCode || e.keyCode || 0;
                    return (
                            key == 13 || //enter
                            (key >= 37 && key <= 40) || //arrows
                            (key >= 48 && key <= 57) || //numbers
                            key == 8 || //backspace
                            key == 9 || //tab
                            key == 46 //delete
                            );
                });
            });
        };

        $(function() {
            $('#<%= txtEIDEntryBox.ClientID %>').filterTextBox();
        });

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating custom result formats through WCF to return JSONP

So, I have a WCF service that gives back a customized object with specific properties that I need to utilize. [DataContract] public class CommonJsonResponse { [DataMember] public object Data { get; set; } [DataMember] public bool Success ...

Using Ajax to make a request on the same page but specifically within a column

I'm currently experimenting with AJAX to display live CSV data on my website. Right now, the AJAX script triggers on button click, but what I really want is for the data to be shown in a grid view without requiring a refresh or clicking a button. Howe ...

Easy task tracker in Vue.js

I’m currently delving into the world of VueJS and working on a simple to-do list application. The issue I’m facing is that I can't seem to successfully pass an array to the child component responsible for displaying the list: Parent Component < ...

What is the best way to determine the appropriate function to invoke using JQuery and Ajax?

I am currently developing a single page application that allows users to run various processes, such as adding new records, updating existing ones, and deleting records when necessary. My main concern is determining the most efficient way to handle these p ...

transferring data from JavaScript to PHP variables

Currently, I am working on a project that involves using ajax to access the database asynchronously. The value retrieved is stored in a JavaScript variable like this: var content=xmlhttp.responseText; My next step is to pass this value to the PHP module ...

What are the steps for defining the maximum and minimum values in AngularJS?

I'm working with the following HTML markup: <div class="input-group-icon">Max <span class="error">*</span> <div class="input-group"> <input style="border-right:none;" name="available_funds_max" ng-model="attributes.avai ...

Using the combination of CakePHP and AJAX for seamless database updates without the need for page

I am currently working with CakePHP 1.3.7 and I have a specific goal in mind: On a certain webpage, I want the user to be able to interact by clicking a link or button that passes a parameter which is then saved into a database, all without the need to re ...

connect the input to a factor using v-model

I currently have a value that I need the user to adjust. Here's my current setup: <input type="number" v-model="value" step="any"/> However, the internal value is in radians while I want the user to see and input a degree value. So, I want th ...

Auto play feature malfunctioning in Onsen-UI Carousel attribute settings

When utilizing onsen UI in my mobile web application, I encountered an issue with the autoplay property not functioning properly within the carousel. <ons-page> <ons-toolbar> <div class="left"> <ons-toolbar-button on ...

A Guide on Integrating a Javascript Reference into HTML while Displaying a PHP Object

Our website relies heavily on PHP modules to generate objects that are essential for constructing our web pages. Some of the key modules we have include: Anchor (ahref) Button CheckBox ComboBox DateTime Email Label Note Password Phone RadioButton RichTe ...

"Exploring the Possibilities: Foundation 4 Reveal and WP AJAX for Creating Previous/Next Modal Windows within an Open Modal

I am currently in the process of developing a personalized gallery that integrates WordPress and Zurb Foundation: The layout showcases an organized collection of custom posts on different pages; these are displayed as a grid of linked thumbnails through ...

Executing asynchronous JavaScript code within a Golang request: a comprehensive guide

I am in need of a solution to retrieve the content from dynamically generated pages using ajax on a website, specifically with code written in golang. I have found examples for non-ajax pages but struggling to find one that works for ajax pages. Any guid ...

Tips for optimizing search functionality in Angular to prevent loading all data at once

An exploration for information within vast datasets is triggered by AngularJS when the input contains more than 3 characters. var app = angular.module('test_table', []); app.controller('main_control',function($scope, $http){ $scope ...

What is the best way to send information using an array of objects?

In my Angular 5 project, I am using the ngx select dropdown package (https://www.npmjs.com/package/ngx-select-dropdown) and I'm wondering how to pass an array of objects instead of an array of strings. Currently, when I do so, it displays [Object Obje ...

Having trouble adding/removing/toggling an element class within a Vue directive?

A successful demonstration can be found at: https://jsfiddle.net/hxyv40ra However, when attempting to incorporate this code within a Vue directive, the button event triggers and the console indicates that the class is removed, yet there is no visual chang ...

Show 1 Blog Post on a Separate AngularJS Page

I would like to show only Test Post 1 on the next HTML page titleDetails.html when the user clicks on Test Post 1 in index.html 1) titleDetails() in index.html: <a ng-click="titleDetails(post)">{{ post.title }} </a> 2) Controller Variables a ...

Ways to retrieve an input field value without triggering form submission

I'm currently working on a payment form where users input the amount in a text field. I also have another text field on the same form that should automatically display the amount in words based on the user input. However, I'm struggling to figure ...

"Creating varying lengths of time with useSpring: A Step-by-Step Guide

Is there a way for my component to have an animation that fully displays in 0.3s when my mouse enters, but disappears in 0.1s when my mouse leaves? Currently, with useSpring, I can only define one duration for both scenarios. How can I set different dura ...

Utilizing React's Conditional Rendering Alongside Bootstrap to Maintain the Layout Intact

I'm currently developing a project using React and Bootstrap that involves incorporating a large bar graph with two smaller boxes, all positioned horizontally together. To visualize how it should appear, please expand the pen window to see them arran ...

Trouble with Mongoose save() function failing to update data

I am currently working on enhancing a fully functioning CRUD app by adding a new feature that allows users to update a list of vendors. They have the ability to add new vendors, update existing ones, and delete vendors. While the add and delete functions a ...