With KoolMaskedTextBox, you can set the format that you need user to key in by using $Mask property.
In the $Mask, there are several parts:
- 1. Number: denoted by '#' character.
- 2. Lower-case char: denoted by 'a' character.
- 3. Uppper-case char: denoted by 'A' character.
- 4. Special char: denoted by '~' character.
There are two type of special mask inputs:
- 1. Range input: User only can enter in a numner range only, for example <0..255>
- 2. Option input: User can only enter some character that you set, for example <m|f|b>
You can set behavior of KoolMaskedTextBox with $SelectionOnFocus when it is focused:
- 1. "None" : Do nothing.
- 2. "CaretToBeginning" : Move the caret to beginning
- 3. "CaretToEnd" : Move caret to the end
- 4. "SelectAll" : Select all the text
After user submit the form, you can get the value from KoolMaskedTextBox through below properties:
- 1. $Value: Exact what user input.
- 2. $ValueWithPrompt: User input and empty space filled with prompt char.
- 3. $ValueWithLiterals: User input and literals from the mask.
- 4. $ValueWithPromptAndLiterals: User input, prompt char in empty space and literals from the mask.
At client-side, you can use:
- 1. set_value(_value),get_value():To set or get the value
- 2. get_value_with_prompt(): User input and empty space filled with prompt char.
- 3. get_value_with_literals(): User input and literals from the mask.
- 4. get_value_with_prompt_and_literals(): User input, prompt char in empty space and literals from the mask.
<?php
require $KoolControlsFolder."/KoolForm/koolform.php";
$myform_manager = new KoolForm("myform");
$myform_manager->scriptFolder = $KoolControlsFolder."/KoolForm";
$myform_manager->styleFolder = "sunset";
$myform_manager->DecorationEnabled = true;
$txtPhone = $myform_manager->AddControl(new KoolMaskedTextBox("txtPhone"));
$txtPhone->Mask = "(###) ###-####";
$txtPhone->PromptChar = "_";
$txtPhone->SelectionOnFocus = "SelectAll";
$txtIPAddress = $myform_manager->AddControl(new KoolMaskedTextBox("txtIPAddress"));
$txtIPAddress->Mask = "<0..255>.<0..255>.<0..255>.<0..255>";
$txtIPAddress->SelectionOnFocus = "CaretToBeginning";
$txtVisaCreditCard= $myform_manager->AddControl(new KoolMaskedTextBox("txtVisaCreditCard"));
$txtVisaCreditCard->Mask = "4### #### #### ####";
$txtVisaCreditCard->PromptChar = "_";
$txtVisaCreditCard->SelectionOnFocus = "SelectAll";
$txtSSN= $myform_manager->AddControl(new KoolMaskedTextBox("txtSSN"));
$txtSSN->Mask = "###-##-####";
$txtSSN->PromptChar = "_";
$txtSSN->SelectionOnFocus = "SelectAll";
//Init form
$myform_manager->Init();
?>
<form id="myform" method="post" class="decoration">
<fieldset style="width:250px;padding-left:10px;padding-bottom:10px;">
<legend><b>Enter following</b></legend>
<div>
Phone: <br/>
<?php echo $txtPhone->Render();?>
</div>
<div style="margin-top:10px;">
IP Address: <br/>
<?php echo $txtIPAddress->Render();?>
</div>
<div style="margin-top:10px;">
Visa Credit Card: <br/>
<?php echo $txtVisaCreditCard->Render();?>
</div>
<div style="margin-top:10px;">
SSN: <br/>
<?php echo $txtSSN->Render();?>
</div>
<div style="margin-top:10px;">
<input type="submit" value="Submit" />
</div>
</fieldset>
<?php echo $myform_manager->Render();?>
</form>