Missed JavaScript Days 2026? The Replays Are Now Available – Watch Now!

Turbocharge Your Business Process Form Input Fields With Ext JS

June 22, 2021 3481 Views

Get a summary of this article:

Forms are a vital part of any digital product that we see today. They are a great way to interact with the users and record their input. They also play a significant role in capturing valuable user feedback as well. Due to its benefits and use cases, many application developers look for quick and easy ways to create business process forms and focus more of their energy on implementing business logic over the design.

In this blog post, we’ll look at how we can make use of Sencha Ext JS and quickly create impressive process forms for our own use cases in arguably the best javascript framework.

Which types of fields are available for creating forms with Sencha Ext JS?

Sencha Ext JS has an entire namespace Ext.form.field dedicated to providing form controls. It has a standard set of field types that you can use to create an end-to-end form panel. These field types include Checkbox, ComboBox, Date, Display, File, Hidden, HtmlEditor, Number, Radio, Text, TextArea, and Time.

For detailed information about these fields, check out their individual documentation.

How can I do validations based on field types?

Client-side validations are equally important as server-side schema and data validations. They help in the identification of incorrect or insufficient information before making API calls to the server. Hence, resulting in lesser network traffic due to correct API calls. Sencha Ext JS supports two types of validations namely built-in and custom validations.

Ext JS has its own set of apparent validation rules for some field types. For instance, in a Date field, if incorrect data is entered which can not be actually converted into the Date instance, Ext JS internally detects it and provides meaningful hints and error messages for the user to rectify their data.

Built In Incorrect Date

With Ext JS, it is fairly easy to change the location of the error message. The following code snippet will move the error message from the default tooltip to a piece of text under the field itself.

{     xtype: 'datefield',     fieldLabel: 'Date of Birth',     name: 'birthDate',     msgTarget: 'under', // location of the error message     invalidText: '"{0}" bad. "{1}" good.' // custom error message text }

The resulting error message will look like follows.

Built In Incorrect Date No Tooltip

While built-in validations are smooth, straightforward, and time-saving, they can be used every time with every field type. Some validation requirements cannot be met using these built-in validation rules.

The simplest way to implement a custom validation is to use the Text Field’s regex configuration to apply validation rules and the maskRe configuration to limit which characters can be typed into the field.

Following is an example of a Text Field that validates a time.

{
    xtype: 'textfield',
    fieldLabel: 'Last Login Time',
    name: 'loginTime',
    regex: '/^([1-9]|1[0-9]):([0-5][0-9])(sm)$/i',
    maskRe: '/[ds:amp]/i',
    invalidText: 'Not a valid time.  Must be in the format "12:34 PM".'
}

The best part about Ext JS is that it allows you to create reusable validation classes that you can use in your application multiple times without duplicating the code.

Following is an example of a validation class that does exactly the same thing i.e. it validates time, but with reusable configurations.

// custom Vtype for vtype:'time'
var timeTest = '/^([1-9]|1[0-9]):([0-5][0-9])(sm)$/i';
Ext.apply(Ext.form.field.VTypes, {
    //  vtype validation function
    time: function(val, field) {
        return timeTest.test(val);
    },
    // vtype Text property: The error text to display when the validation function returns false
    timeText: 'Not a valid time.  Must be in the format "12:34 PM".',
    // vtype Mask property: The keystroke filter mask
    timeMask: '/[ds:amp]/i'
});

What is an easy way to implement a form submit functionality?

Submitting a form is extremely simple and straightforward with Sencha Ext JS. Ext JS allows you to configure the server URL in the form class and define the submit button along with its callback handler.

After setting up the URL and submission handler, your form should look somewhat like this.

Ext.create('Ext.form.Panel', {
    ...
    url: 'add_user',
    items: [
        ...
    ],
    buttons: [
        {
            text: 'Submit',
            handler: function() {
                var form = this.up('form'); // get the form panel
                if (form.isValid()) { // make sure the form contains valid data before submitting
                    form.submit({
                        success: function(form, action) {
                           Ext.Msg.alert('Success', action.result.msg);
                        },
                        failure: function(form, action) {
                            Ext.Msg.alert('Failed', action.result.msg);
                        }
                    });
                } else { // display error alert if the data is invalid
                    Ext.Msg.alert('Invalid Data', 'Please correct form errors.')
                }
            }
        }
    ]
});

That’s all there is to it. For more information about forms, check out our detailed guide.

Ready to get started with Sencha Ext JS? Head over to Sencha Ext JS and create your own business process forms now.

Author

Emad Bin Abid

I'm a software engineer who has a bright vision and a strong interest in designing and engineering software solutions. I readily understand that in today's agile world the development process has to be rapid, reusable, and scalable; hence it is extremely important to develop solutions that are well-designed and embody a well-thought-of architecture as the baseline. Apart from designing and developing business solutions, I'm a content writer who loves to document technical learnings and experiences so that peers in the same industry can also benefit from them.

Recommended Articles

Generating Live Ext JS Database Applications with Indi Engine AI: A Practical Architecture for Enterprise Modernization

Modernizing enterprise applications is rarely a matter of replacing an old interface with a new one. The deeper challenge is preserving the data structures, business…

Building High-Performance Real-Time Operational Dashboards with Ext JS and React

Real-time operational dashboards are no longer simply reporting interfaces. In logistics, fleet management, supply chain operations, financial services, and other data-intensive environments, they are part…

What JS Days 2026 Keynote Revealed About the Next Era of Development

The JavaScript ecosystem has spent the last decade optimizing for speed. Frameworks have become more capable, development tooling more sophisticated, and release cycles increasingly rapid.…

Async/await with Ext JS

Probably one of the most appreciated features of the latest versions of JavaScript is Promises, and in particular their use through the new language keywords…

Sencha IDE Plugins – JetBrains 6.0.18 Is Here

JetBrains 2026.2 just shipped. So did we. Sencha’s JetBrains plugin is an Integrated Development Environment tool that creates a confluence between Sencha Frameworks and JetBrains…

Building Responsive, Data-Driven Enterprise Applications with JavaScript

In enterprise software, responsiveness is no longer a nice-to-have. Users expect the same application to perform smoothly whether they are working at a desktop with…

View More