EasyUI Forum
April 29, 2024, 12:46:43 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: MaskedBox Required TRUE not working?  (Read 933 times)
Spike
Newbie
*
Posts: 22


View Profile
« 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
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 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%">
Logged
Spike
Newbie
*
Posts: 22


View Profile
« Reply #2 on: February 05, 2024, 06:26:51 AM »

Thanx Jarry!

I will give it a try !
Logged
Spike
Newbie
*
Posts: 22


View Profile
« Reply #3 on: February 05, 2024, 06:42:30 AM »

Up and running! thanx
Logged
Spike
Newbie
*
Posts: 22


View Profile
« Reply #4 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
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!