<s:TextInput id="bill" x="150" y="17" width="223"
borderColor="#FFFBFB" borderVisible="false"
color="#EF4315" contentBackgroundColor="#100101"
enabled="false" fontWeight="bold" restrict="0-9"
text="0.00" textAlign="right"/>
"0-9" restricts my textInput field to numeric values
and a decimal point. Is there a way I can extend this so only
two places follow the decimal?
Unfortunately you can not. But you can listent to CHANGE Event and programmatically force this on the TextInput.
Related
I am trying to add some text before each Proformtext component, but it is not appearing
Below is my code
<ProFormFieldSet
name="firstrow"
label={<span style={{fontSize: fontSize}}>A</span>}
labelAlign={labelAlignment}
>
<ProFormText
addonBefore="helloworld"
labelAlign={labelAlignment}
width="md"
/>
=
<ProFormText
addonBefore={C}
width="md" />
</ProFormFieldSet>
This is the Actual result
Expected Result
There is text beside each input.
What I have tried
I took ProFormText component out from ProFormFieldSet and the text appear. anyone know why this is happening??
according to the reference, the props we set for ProFormText are actually for Form.Item, and the fieldProps are for the included Input, remember. pro-form-fields-reference
have a try like below
<ProFormFieldSet
name="firstrow"
label={<span style={{fontSize: fontSize}}>A</span>}
labelAlign={labelAlignment}
>
<ProFormText
fieldProps={{addonBefore:"helloworld"}}
labelAlign={labelAlignment}
width="md"
/>
=
<ProFormText
fieldProps={{addonBefore: C}}
width="md" />
</ProFormFieldSet>
I was tring to use material component in angular 2 dart as a number input:
<material-input type="number"></material-input>
but it behaves like a normal input. In docs it sais it supports type "number". Am i doing anything wrong? Or isn't number type implemented yet?
Thank you for any suggestions.
I can share my personal experiment trying to have a number (integer) input. It does not work perfectly on all browsers but I wanted to have the proper keyboard shown on Android and iOS. What I did was forcing the type on the inner input element programmatically. It seems that on Firefox it does not prevent entering text but does display a message ("Please enter a number"). It does not handle decimal neither (i.e. it does expect an integer)
initInputNumber(MaterialInputComponent inputComponent) {
inputComponent.type = "number";
InputElement inputElement = inputComponent.inputEl.nativeElement;
inputElement.type = "number";
// http://stackoverflow.com/questions/6178556/phone-numeric-keyboard-for-text-input
// As of mid-2015, I believe this is the best solution:
// <input type="number" pattern="[0-9]*" inputmode="numeric">
inputElement.attributes["inputmode"] = "numeric";
inputElement.pattern = "[0-9]*"; // this and only this works 0-9
}
I don't know if that's the best solution but I find it hard to have a complete cross-browser solution
I think you need to set an errorMsg
<material-input type="number" errorMsg="That's not a number"></material-input>
This line https://github.com/dart-lang/angular2_components/blob/a0eff879a6cb347b8beb95ed758c02c6dd9dfaa0/lib/src/components/material_input/material_input.dart#L232 seems to indicate that type="tel" and type="number" are set to text for the internal input element, while this line https://github.com/dart-lang/angular2_components/blob/a0eff879a6cb347b8beb95ed758c02c6dd9dfaa0/lib/src/components/material_input/material_input.dart#L61 says that errorMsg is used when and invalid number is entered when type="number".
I am developing a WPF application for arabic users using vb .net.
In the application the user has to enter in a textbox the following: "22/85/39" but unfortunately after entering it, it displays the reverse (i.e. 39/85/22).
This is my xaml code:
<TextBox x:Name="txtWorkingNumber" Height="26" VerticalAlignment="Center" HorizontalAlignment="Left" Width="200"
Text="{Binding WorkingNumber}"
FlowDirection="RightToLeft"
Language="ar-SA"
NumberSubstitution.Substitution="AsCulture"/>
I have tried all Substitution enumerations but failed to find the fix.
Could any one give me a help on how to fix it??
many thanx...
Finally I found the solution which is, to add white space at the end of the text where you type "/" sympole. This is achieved through this code snippet added to the code behind:
Private Sub TextBox_PreviewKeyDown(sender As Object, e As System.Windows.Input.KeyEventArgs)
Dim myTextBox As TextBox = CType(sender, TextBox)
If Thread.CurrentThread.CurrentCulture.ToString.StartsWith("ar") Then
If e.Key = System.Windows.Input.Key.Divide Then
myTextBox.Text += " "
myTextBox.CaretIndex = myTextBox.Text.Length
End If
End If
End Sub
I have a problem. I am trying to save a information into the database, and before that I check some conditions like if-else like:
if(condition){
//Some Action
}else{
getFacesContext().addMessage(null,MessageFactory.getMessage(ResourceBundle.FACES_BUNDLE.getName(), FacesBundle.LANDLINE_NUMBER_SHOULD_BE_TEN.getName()));
getExternalContext().getFlash().setKeepMessages(true);
return;
}
and When the condition does not match I would like to restore the previous values of the input field.
In that case, it was 22 in place of ss. but the field does not take input except numbers. So the validation fails and shows an message Invalid Input via growl.
How can I also reset the value of the field ss to 22 in java?
Please suggest!
You can use default validator that comes with JSF
<p:inputText id="number" value="" label="Number">
<f:validateDoubleRange minimum="0" maximum="99" />
</p:inputText>
<p:message for="number" />
But if you reset the filed with old value, user may not know what he's entered. However you will not submit until validation success.
Since the input text component implements EditableValueHolder you can call EditableValueHolder.resetValue() on the input component (or call the more convenient RequestContext.getCurrentInstance().reset(inputTextId)) and then re-render it by calling RequestContext.getCurrentInstance().update(inputTextId) if it isn't already being re-rendered through the update attribute of p:ajax.
I am working on a Firefox extension. I have a simple single-line textbox. When a user pastes in text, I want to detect if the text has newlines and if it does, I want to expand the textbox into a multiline textbox.
I have
<textbox id="textbox" rows="5" wrap="off" newlines="pasteintact" oninput="adjustTextbox(this)" flex="1"/>
and on the JS side, I have
adjustTextbox(txtBox) {
if(!txtBox.getAttribute('multiline') && txtBox.value.match(/[\r\n]/)) {
txtBox.setAttribute('multiline', true);
}
}
The problem is that, while the textbox does get converted to a 5 row multiline textbox, the value that is pasted in is lost and the textbox is blank. Am I doing something wrong here?
Short answer: no, you aren't doing anything wrong, the value is expected to be cleared when you switch from single-line to multi-line. Long answer: the <textbox> element doesn't actually hold the value itself, it rather contains an anonymous <html:input type="text>. When you add the multiline attribute a different XBL binding applies to the element and that anonymous text field is replaced by <html:textarea>. Obviously, the value gets lost in the process.
You could try to save the value and to restore it after you add the multiline attribute. The problem is that it is hard to tell when the binding actually applies, there is a delay that is not really predictable. So the better solution would be to have both a single-line and a multi-line text box in your document and make sure that one of them is always collapsed:
<textbox id="textbox" newlines="pasteintact" oninput="adjustTextbox(this)" flex="1"/>
<textbox id="textbox2" collapsed="true" multiline="true" rows="5" wrap="off" flex="1"/>
And on the JavaScript side:
function adjustTextbox(txtBox) {
if(!txtBox.getAttribute('multiline') && txtBox.value.match(/[\r\n]/)) {
var txtBox2 = document.getElementById("textbox2");
txtBox2.value = txtBox.value;
txtBox.collapsed = true;
txtBox2.collapsed = false;
}
}