Masked Input In Active Form

I Try to add MaskedIput on my form but it does nothing, i add this




<?php

echo MaskedInput::widget([

    'name' => 'plateNumber',

    'mask' => 'a?a-9?999?-aaa',

    'placeholder' =>'__-____-___'

]);

?>



Any sugesstion? Thanks before

From my reading of the docs, it looks like the first question mark character will make all following characters optional. Is that what you were intending?

Are you getting any errors in your browser’s console?

Yes, i intending to make it optional. but what i want to ask is how to get masked input to work. i wrote the code from the docs but masked in put not work, it only show like text input without masked input ability

Am i wrong in writing the code? Thanks

Is your browser console reporting any errors?

No, but masked input rendered just like normal text input in browser with no masked input ability, i can input all character without error

The masked input is a normal text input until the javascript code is attached. That’s why there’s likely a problem somewhere in your javascript code. Possible issues are that a script such as jQuery has been included more than once or that there’s another javascript error somewhere on your page.

The simplest way for someone here to resolve it might be to paste the generated HTML source of your page into something like pastebin and post a link here.

Yeah, you right, my bad. after you mention it i check generated source for


<?php

echo MaskedInput::widget([

    'name' => 'plateNumber',

    'mask' => 'a?a-9?999?-aaa',

    'placeholder' =>'__-____-___'

]);

?>

it show only like this


<input type="text" id="w0" class="form-control" name="plateNumber">

i will try to figure out what happening. thanks for sugestion.

That’s probably what you’d expect. The script is likely attached in a script section towards the end of your page.

After update yii2 via composer, masked input works. but now i have another problem. i need help figuring mask setting for ip address, i already tried this




<?=

    MaskedInput::widget([

        'model' => $model,

        'attribute' => 'ip_address',

        'name' => 'ip_address',

        'mask' => '9?99.9?99.9?99.9?99',

    ]);

?>



in browser placeholder show like this .___.___.

when i want to add 9.9.9.9 so i type 9__.9__.9__.9 and i change the cursor position to another field mask input field value dissapear. i expecting input mask widget work like this http://igorescobar.github.io/jQuery-Mask-Plugin/

Thanks before