Error Message for Error State in input - sapui5

Is there a possibility to define own error messages for an input?
View
<Input id="inputReferenceId" change="handleChangeReferenceId" type="Text" />
I change the state this way:
Controller
handleChangeReferenceId: function(oEvent){
if(...)
this.byId("inputReferenceId").byId("inputReferenceId").setValueState(sap.ui.core.ValueState.Error);
//I need a own error message for the inputReferenceId input
}
}
I need a own error message like "Please fill in a valid Reference Number"
Is there a attribute like valueStateText or something?

It works. It was my fault. If the cursor leaves the field there is no valueStateText. onFocus the input field the text appears.

Here is a property:
valueStateText

Please check you SAPUi5 library version, as this valueStateText property is available from 1.26.0 onwards.

Related

Angular Material forms validation error message won't go away

I have a material form in which I have an MdInput:
<md-form-field class="input-full-width">
<input mdInput class="form-control" type="text" placeholder="Description" formControlName="periodDesc">
<md-error *ngIf="fb.get('periodDesc').errors.required">This field is required</md-error>
</md-form-field>
The validate message appears when the field has been touched but no text has been typed in. However, the validate message persists even when I try to type in text there:
Edit 1:
The issue gets fixed when I do this instead:
<md-error *ngIf="fb.hasError('required', ['periodDesc'])">This field is required</md-error>
However, my question is why did the issue occur in the first place? Is there anything wrong with the previous case because I am using it in other places where the second one won't work. Ref: Angular Material forms validation errors
The reason is that When a formControl has no validator errors(see here), fb.get('periodDesc').errors will return null. So your current way will throw null error like can not find required of null.
Use fb.get('periodDesc').hasError('required') instead of fb.get('periodDesc').errors.required to prevent from above error.

Changing Wicket text field validation error message

I have a text field that uses a PropertyModel, like this:
TextField<Integer> ageField = new TextField<Integer>("age",
new PropertyModel<Integer>(person, "age"));
When a non-integer value is submitted, the following error is displayed in the browser:
"The value of 'age' is not a valid Integer."
How can I modify this error message?
In Wicket 6 you need to set up a properties file with the inputs Wicket-ID appended by .Required:
myinput.Required = Please provide this input field
Define own feedback messages in Wicket
Create a properties file and specify your own message:
TextField.age=Your custom message
More info about properties here and here
Add
age.IConverter.Integer = Your Custom Message
to your properties file
What worked for me was adding this to the properties file:
<entry key="IConverter.Integer">${label} must be an integer.</entry>

Pass alternate attribute as GET

I have the following input:
<input id="whereInput" type="text" name="where" placeholder="around..." geodata="-73.6050237,45.5511518" value="Current Location">
I want to pass the geodata as the value to the get parameter, but not its value.
in other words I want where=-73.6050237,45.5511518 but not where=Current%20Location
Thanks,
Store the value you actually want to submit in a hidden input with a different name.
If the submitted value is "Current Location" then read the data from the other field instead.

Commonspot forms hidden field values

I have a form in commonspot, which uses hidden field to pass the information to next form,which it got from a previous form, but I'm not sure about the syntax for the default value of hidden fields. I have tried using form.fieldname, evaluate(form.fieldname), and #form.filedname#.
Can anyone help me with this ?
Thanks,
AA
Ardash - you should paste some actual code to help us understand what you mean.
In general if you want a "default" value (for the case where the item doesn't exist previously) you should use cfparam like so:
<cfparam name="form.myField" default="*some default value*"/>
Then in your hidden field you can safely do this:
<input type="hidden" name="myField" value="<cfoutput>#form.myField#</cfoutput>"/>
Hope this helps. Paste some code for a better response :)
You can list the field names submitted to the page using this method:
<cfoutput>#form.fieldnames#</cfoutput>
alternatively, you can get the field names and data:
<cfdump var="#form#">
This might help you figure out what is going on.

Getting a value from a label at POST

There's a place into my screen that I populate a label with a specific string value after some interaction with my user during the runtime. I use javascript for that.
Is there anyway to get the value of this lavel with my controller after its POST method is activated ?
Thanks, guys !
Option #1
Put the value in an HTML <input> element with a name attribute? Might need to dress down
the input element, since it will look like a textbox.
Option #2
Mirror the value in a hidden input <input type="hidden" value="yourValue" /> inside the form you're posting.