How to mask textfield value in ext.net - textfield

I have textfield and i want to mask like that 999.99.99.99.99 I try this
<ext:TextField ID="txtNumber" runat="server" AllowBlank="false"
>
<Plugins>
<ext:InputMask ID="InputMask1" runat="server" Mask="999.99.99.99.99.99" ClearWhenInvalid="False" />
</Plugins>
</ext:TextField>
also the user can enter 999.99 or 999 or 999.99.99 kind of value in this textfield. How can i manage it.
Thank you

U can try regex instead of mask. ext:TextField has the Regex property.

You can define a MaskSymbol as the third field in this example: Form > TextField > InputMask.
And use a regex like #CocLn suggested. Maybe something like this:
<ext:TextField ID="txtNumber" runat="server" AllowBlank="false">
<Plugins>
<ext:InputMask
ID="InputMask1"
runat="server"
Mask="999~"
ClearWhenInvalid="False">
<MaskSymbols>
<ext:MaskSymbol Name="~" Regex="(\.[0-9]{2}){0,4}" />
</MaskSymbols>
</ext:InputMask>
</Plugins>
</ext:TextField>
This should require 3 digits and a sequence 0 to 4 times of a dot followed by two digits. If the first digit after each dot is optional (e.g. 999.9.99 is valid), then just turn the {2} bit into {1,2}.

Related

XPATH text set dynamic value base on the language

For example "//XCUIElementTypeStaticText[#text='Accept All']"
which name 'Accept All' can be changed base on the language, for example, Spanish will change to 'Aceptar todas'
example :
<android.widget.TextView index="0" package="com.android.chrome" class="android.widget.TextView" text="Aceptar todas" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[412,1386][669,1438]" displayed="true" />
In this case how to make sure this XPath works with this condition?
You can pass the language string as parameter.
You didn't mention what language you are using, so I will use Java here, but this can be done with any other language similarly.
Let's say we are passing the language as language string parameter.
String xpathTemplate = "//XCUIElementTypeStaticText[text()='%s']";
String xpath = String.format(xpathTemplate,language);
driver.findElement(By.xpath(xpath));
Can you try something like
//android.widget.TextView[#index='0'] or //android.widget.TextView[0]
here is reference : Xpath for Android element using Appium

Struts Formatting

I am trying to format a double value to two decimal places in a struts <html:text> tag. ex)
<html:text property="freight" size="9" maxlength="9" />
the value inside freight is a double for example $100. When it displays, it shows it as 100.0, not 100.00 (like I want it to).
I would like to display all double values to two decimal places but the <html:text> does not have a format property.
Could someone please help?
You can use <s:text> tag to do it.
Add a formatting entry to a .properties file (probably package.properties)
format.twodecimalnumber={0,number,#0.00}
Then in your view (JSP) file, the following code can be used for displaying a formatted number
<s:text name="format.twodecimalnumber">
<s:param name="value" value="53.3" />
</s:text>
If you want the formatted number to be displayed in an input textbox, you can wrap the above code inside a <s:textfield> tag. Like so -
<s:textfield>
<s:param name="value">
<s:text name="format.twodecimalnumber">
<s:param name="value" value="53.3" />
</s:text>
</s:param>
</s:textfield>
Refer https://struts.apache.org/release/2.0.x/docs/formatting-dates-and-numbers.html

Using EL in <jsp:include> tag

i have a jsf 1.2 / rich faces 3.2.2 project (with java 6). i want to display menu bar conditionally depending on type of user logged in. From the question How to conditionally include a file in my template using JSF and Facelets? i tried the following:-
...
<td valign="top" align="left" height="100%">
</f:verbatim>
<jsp:include page="../Menu${authenticateBean.menuSuffix}.jsp" /> <f:verbatim></td>
...
i also tried
<jsp:include page="../Menu#{authenticateBean.menuSuffix}.jsp" />
...
where authenticateBean.menuSuffix is a string that will return "A" or "B" and ultimately, theoretically "MenuA.jsp" or "MenuB.jsp" page should include in my page. but i get following error
javax.servlet.ServletException: File "/pages/includes/LeftPan.jsp" not found
Help. Plz.
Heres how I managed it. Placing as an answer if ne one needs…
<%
AuthenticateBean authBean=
((AuthenticateBean)FacesUtils.getManagedBean(AuthenticateBean.MANAGED_NAME));
String panSuffix = authBean.getPanSuffix();
String impPage = "../includes/Menu"+ panSuffix +".jsp";
%>
.
.
.
<jsp:include page="<%= impPage %>" />
In the getPanSuffix() i have placed business logic that checks the type of user logged on and return a string accordingly. for Type "A" user. MenuA.jsp would display and for type "B" user MenuB.jsp would display. May be a primitive way of doing things but worked for me.
Thanks All.

Do hidden input fields have to be escaped in ColdFusion?

Using ColdFusion 8 I usually escape all my form inputs like so:
<input id="foo" value="#XMLFormat(trim( form_name.param_name ))#" />
So how about hidden inputs? Should these also be escaped? I haven't tried, but I could very well pull a hidden input up in Firebug, enter whatever and try to submit, can I?
The goal of escaping in this case is to keep the HTML well formed so yes - hidden vars need to be escaped (or encoded) as well. I usually use urlencodedformat() for this. Consider what would happen if the value you were placing in the hidden var were a variable like this:
<cfset form.fullname= 'Bob "the tiger" Johnson'/>
<input type="hidden" name="fullname" value="#form.fullname#"/>
The output would actually look like this:
<input type="hidden" name="fullname" value="Bob "the Tiger" Johnson"/>
This would mean your hidden var would come through as "Bob " ... and the rest would be lost. The situation might get worse if any part of your strings contain HTML or slashes or angle brackets.

How to trim input field value in struts?

I use Struts v1.3 and have following input form:
In struts-config.xml:
<form-bean name="testForm"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="displayName" type="java.lang.String" />
</form-bean>
In validation.xml:
<form name="testForm">
<field property="displayName" depends="required">
<arg key="input.displayName" />
</field>
</form>
How do I trim value of "displayName"? How do I trim values of all "java.lang.String" input fields of the form?
You may have a chance to trim the string right at the moment, the request processor updates the data from the input fields to the form. This was not tested, but what happens when you modify the setter setDisplayName(String displayName) to something like
public void setDisplayName(String displayName) {
this.displayName = displayName.trim();
}
This is not a very good solution, because it migrates logic into a setter.
regards
If you want to use trim for validation purposes, I think the proper way is to create and use your own (or extend an existing) validator for required fields that takes trim into consideration.
For an example, you can use this page: http://struts.apache.org/1.2.4/userGuide/dev_validator.html, the section "Pluggable Validators".
If you want to use trim for trimming the String values before using them in your business logic, you can extend org.apache.struts.validator.DynaValidatorForm and overwrite the methods that retrieve values, like get(String name), getString(String name) and so on. After that, you use your class in the form-bean declarations.
If you don't mind having String manipulation logic in your Form class, you can try the StringUtils methods in Apache's Commons Lang JAR:
StringUtils JavaDoc
This will let you trim your Strings in a number of specific ways, whether you want to trimToEmpty, trimToNull, etc. This means you have access to null-safe methods, which can be useful with some values.
Alternatively try using javascript regexp in the jsp that will trim onfocus or onblur
< html:text name="testForm" property="displayName" onfocus="javascript:this.value=this.value.replace(/^\s+|\s+$/g,'')" onblur="javascript:this.value=this.value.replace(/^\s+|\s+$/g,'')" />