Theme:
Processing...
Description & Source Code

The watermark and masking features (also called input prompt) guide users in filling out an input with the specified format.
ZK's strong integration of jQuery allows developers to leverage the vast jQuery libraries to achieve the desired effects.

In this demo, the masked input and watermark input plugins are used.

Default Mask
  • a - Represents an alpha character (A-Z,a-z)
  • 9 - Represents a numeric character (0-9)
  • * - Represents an alphanumeric character (A-Z,a-z,0-9)
Customize Mask
  • m - Represents a numeric character (0-1)
  • d - Represents a numeric character (0-3)
  • y - Represents a numeric character (2-2)
  • A - Represents an alpha character (A-Z)

form_effect.zul
<zk xmlns:w="client">
	<style src="/widgets/effects/form_effect/styles.css"/>

	<!-- Load the script -->
	<script type="text/javascript" src="/widgets/effects/form_effect/jquery.watermarkinput.js" />
	<script type="text/javascript" src="/widgets/effects/form_effect/jquery.maskedinput.min.js" />
	<script type="text/javascript">
		/* customize mask character groups */
		$.mask.definitions['A']='[A-Z]';
		$.mask.definitions['m']='[01]';
		$.mask.definitions['d']='[0123]';
		$.mask.definitions['y']='[12]';
	</script>

	<script><![CDATA[
		function pwdValid(pwd2) {
			var valLabel = zk.$('$pwd_val');
			if (pwd2.getValue() == '') {
				valLabel.setValue('Client Side Validation');
				return;
			}
			var matching = pwd2.getValue() == zk.$('$pwd').getValue()
			valLabel.setValue(matching ? 'OK !' : 'Not Matching !');
		}
	]]></script>
	<div width="500px" class="form">
		<vlayout spacing="7px">
			<label value="On-line Shopping Info" style="font-size:16px;font-weight:bold;color:gray;" />
			<hlayout spacing="20px" valign="middle">
				<label class="name" value="Name :" />
				<textbox id="username" width='150px' w:onBind="jq(this).Watermark('Your Name','gray')"/>
				Watermark
			</hlayout>
			<hlayout spacing="20px" valign="middle">
				<label class="name" value="Phone :" />
				<textbox id="phone" width='150px' w:onBind="jq(this).mask('(999) 999-9999');"/>
				Mask : (999) 999-9999
			</hlayout>
			<hlayout spacing="20px" valign="middle">
				<label class="name" value="Birthday :" />
				<textbox id="date" width='150px' w:onBind="jq(this).mask('m9/d9/y999');"/>
				<label value="Mask : m9/d9/y999" />
			</hlayout>
			<hlayout spacing="20px" valign="middle">
				<label class="name" value="Country Code:" />
				<textbox id="country" width='150px' w:onBind="jq(this).mask('AA');"/>
				<label value='Mask : AA (Upper-Case)' />
			</hlayout>
			<hlayout spacing="20px" valign="middle">
				<label class="name" value="Credit Card:" />
				<textbox id="cc" width='150px' w:onBind="jq(this).mask('9999-9999-9999-9999');"/>
				<label value='Mask : 9999-9999-9999-9999' />
			</hlayout>
			
			<hlayout spacing="20px" valign="middle">
				<label class="name" value="Password: " />
				<textbox id="pwd" type="password" width="150px" />
			</hlayout>
			<hlayout spacing="20px" valign="middle">
				<label class="name" value="Re-type:" />
				<textbox type="password" width="150px" w:onChange='pwdValid(this)' />
				<label id="pwd_val" value="Client Side Validation" />
			</hlayout>
		</vlayout>
	</div>
	<div id="result" /> 
</zk>