I am trying to make a regex check for my time input text and also I am trying to mask the input. I don't know if both can be done at the same time with this code:
<p:inputMask mask="99:99" size="5" maxlength="5" required="true" requiredMessage="#{account_req_txt}" value="#{user.accountNo}">
<f:validateRegex pattern="[01]?[0-9]|2[0-3]):[0-5][0-9]"/>
<p:ajax event="blur" update="sysMsg" />
</p:inputMask>
I am getting "must be a number consisting of one or more digits." error. What is wrong with above code?
How exactly is the "account number" as represented by #{user.accountNo} a time? That part is confusing. In any way, the error suggests that the accountNo is actually a Number like Integer, Long, etc, not a String.
Perhaps you meant to bind it to #{user.time} or something else. At least, the value must be bound to a String, otherwise you need to create a Converter to convert between a String in 99:99 representation to a number type in 9999 representation.
Related
it is possible to slice a string list, like the element line on the Address? I'm trying to do something like that: https://simplifier.net/redenacionaldedadosemsaude/brendereco, but when I generate my IG, my sample resource does not validate the lines.
my resourse example address element:
<address>
<use value="home"/>
<type value="physical"/>
<text value="1003 Healthcare Drive, Northfield MN" />
<line value="street"/>
<line value="Healthcare Drive"/>
<line value="1003"/>
<line value="neighborhood"/>
<city value="Northfield"/>
<state value="MN"/>
<postalCode value="12345123" />
<country value="Brasil" />
</address>
Errors I got on my IG:
When you slice and declare a discriminator, then every slice needs to establish a value for that discriminator. You sliced by Address.line.value by value. That means that each line slice needs to specify a required value set binding, a fixed value or a pattern. (And the constraints declared by each slice can't overlap.) You only declared a required binding on one of the slices. The street, number, complement and neighborhood slices are unconstrained. That's not allowed.
Given that, realistically, you can't define value sets (let alone fixed values or patterns) for those elements, I don't think slicing is going to be possible with just 'value'. If you need to distinguish between different repetitions of Address.line, you're going to need to put an extension on them that indicates what type of line they are.
Also, it's not clear that you're using 'line' correctly. An address line is a string of text that appears on a separate line. It's not just a distinct part of the address. Unless streetType, street, number, complement, etc. all need to appear on separate lines, you can't create separate repetitions of 'line' for them. If you want to break out the parts of the address, you need to use extensions. There are already standard extensions for most 'parts' of an address - you can see them here: https://build.fhir.org/datatypes-extras.html#Address
For the input text field below,
User can enter the values between one and 99,999.
Enter only numbers.
<p:message for="usage" display="text"><p:autoUpdate/></p:message>
<p:inputText id="usage" maxlength="10" required="true"
requiredMessage="You must provide an input" value="#{powerMB.usage}">
<f:validateDoubleRange minimum="1" maximum="99999" for="usage" />
<p:keyFilter regEx="/[0-9]/i" />
</p:inputText>
Current Input values accept - examples
1
34
99
3534
53535
I have tried to mask a specific input values as per
How to restrict Primefaces inputMask to numbers only?
https://www.primefaces.org/showcase/ui/input/inputMask.xhtml
Tried to add a comma for numbers more than 999
I receive the following error for the code below
usage: Validation Error: Value is not of the correct type
<p:message for="usage" display="text"><p:autoUpdate/></p:message>
<p:inputMask id="usage" maxlength="5" required="true"
requiredMessage="You must provide an input" mask="99,999" value="#{powerMB.usage}">
<f:validateDoubleRange minimum="1" maximum="99999" for="usage" />
</p:inputMask>
Input Given as
1 fail validation error
34 fail
99 fail
3534 fail
53535 fail
00,001 fail validation error
00,034 fail
00,099 fail
03,534 fail
053,535 fail
unable to accept input values after I use inputMask
Can provide a full working code of the existing functionality if needed.
This is not the answer to your requirement but it is an explanation on why you see the behaviour you see.
All your failures are easily explained...
The comma is required so all these rightfully fail
1 fail validation error
34 fail
99 fail
3534 fail
53535 fail
Secondly your maxLength is 5 so all these rightfully fail since the length is 6
00,001 fail validation error
00,034 fail
00,099 fail
03,534 fail
And this fails for a combination of reasons
053,535 fail
SNAFU
To make the comma optional look for better matching patterns. It is for me beyond the effort I want to put in this.
#broswer.text_field(:id => 'mobile1').set "07888888888"
<input type="number" class="mobileno required" name="mobile_field" id="mobile1">
The first line corresponds to when i am trying to set a number in the text field, but the problem is that when it inserts the number into the text field the zero gets deleted and thus number remaining in the field is just '7888888888' which is not a valid number and thus the validation fails. I have tried using send keys method and even editing the value of the text field but nothing works. Any help is appreciated.
as you said manually it removed 0 from text_filed, You might want to try execute_script to check how application behaves.
#browser.execute_script("$('text_field#mobile1').val('07888888888')")
change the input type to text.
if your database demands an integer, then you'll have to convert the text string to an integer in your controller. The problem here (i'm pretty sure) is that the zero will be eliminated when it is saved to the database.
hope this helps.
Warning: untested code
I want to use the "data-error-message" to display custom text for a filed if its not filled. Alternatively I want to show custom text "data-type-number-message" if the field does not contain a number.
They do not seem to work together? My code below...
<input name="port" type="text" id="port" size="25" data-required="true" data-error-message="Port is required." data-type="number" data-type-number-message="Numbers Only"/>
Thoughts?
You should be using data-required-message instead of data-error-message for the "Port is required" message.
Also, you may want digits instead of number if this is for a port-number field.
You can use "data-error-message" or "data-parsley-error-message", depending on your install, for a generalized error response.
I'm trying to show a currency dynamicly, that works totally fine!
But I'd like to change the pattern from "SFr. 150'000.00" to "150'000.00 SFr." (and still keep it dynamicly!)
Any suggestions how I could do that?
Here is the code:
<fmt:setLocale value="${pageContext.request.locale}" scope="session" />
<fmt:formatNumber type="currency" value="${investVolume}" />
Thanks in advance!
<fmt:formatNumber type="currency" value="${investVolume}" pattern="###,###.## ¤"/>
The pattern attribute follows DecimalFormat rules.
The ¤ in the pattern represents the currency symbol.
Although I'm not sure if that ' would show in an upper or lower position this should be the way to go.