简体   繁体   中英

Extjs Block HTML tag as input in textfield and textarea

Extjs Block HTML tag as input in textfield and textarea

If the user enter html tags inside the input fields it is executed as html.

If your problem is that users can execute html in your textarea you can simply use some controls or marks to take care about the user injection.

you can use to solve that:

maskRe : RegExp

An input mask regular expression that will be used to filter keystrokes (character being typed) that do not match. Note: It does not filter characters already in the input.

or also a validator function like this:

validator : Function

A custom validation function to be called during field validation (getErrors). If specified, this function will be called first, allowing the developer to override the default validation process.

Ext.create('Ext.form.field.Text', {
    renderTo: document.body,
    name: 'phone',
    fieldLabel: 'Phone Number',
    validator: function (val) {
        // remove non-numeric characters
        var tn = val.replace(/[^0-9]/g,''),
            errMsg = "Must be a 10 digit telephone number";
        // if the numeric value is not 10 digits return an error message
        return (tn.length === 10) ? true : errMsg;
    }
});

have a look to sencha docs here: http://docs.sencha.com/extjs/5.1/5.1.2-apidocs/#!/api/Ext.form.field.TextArea

comment if there are other ploblems. check my answer as correct if all is clear.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM