EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Spike on February 02, 2024, 05:52:03 AM



Title: MaskedBox Required TRUE not working?
Post by: Spike on February 02, 2024, 05:52:03 AM
Hello Support,

MaskedBox Required-TRUE not working?

How can we do that?

All other boxes working perfectly.

Thanks in advance for your help.

Hans Spiike


Title: Re: MaskedBox Required TRUE not working?
Post by: jarry on February 05, 2024, 01:52:16 AM
This is the possible solution for maskedbox.

1. Extend a new validation type.
Code:
$.extend($.fn.validatebox.defaults.rules, {
notempty: {
validator: function (value, param) {
var opts = $(this).parent().prev().maskedbox('options');
var tt = (value || '').split('');
var vv = [];
for (var i = 0; i < opts.mask.length; i++) {
if (opts.masks[opts.mask[i]]) {
var t = tt[i];
vv.push(t != opts.promptChar ? t : '');
}
}
return vv.join('') != '';
},
message: 'The field is required.'
}
});

2. Attach it to the maskedbox.
Code:
<input id="mb" validType="notempty" class="easyui-maskedbox" mask="(999) 999-9999" label="Phone Number:"
labelPosition="top" style="width:100%">


Title: Re: MaskedBox Required TRUE not working?
Post by: Spike on February 05, 2024, 06:26:51 AM
Thanx Jarry!

I will give it a try !


Title: Re: MaskedBox Required TRUE not working?
Post by: Spike on February 05, 2024, 06:42:30 AM
Up and running! thanx


Title: Re: MaskedBox Required TRUE not working?
Post by: Spike on February 06, 2024, 01:44:24 AM

Hi Jarry,

Required is working fine.

Is it possible that required is still ACTIVE till whole maskedit is complete?

Now required is already okay after one character. And not fulfill the whole mask.

Thanx in advance

Hans Spike