Equivalent of Classic maskRE in Modern - extjs

I am migrating our app from Classic to Modern using sdk 7.4
In classic the Ext.form.field.Text class has a maskRe config that will limit what characters the user can input into the field - for example /[0-9"]/ will limit the input to the digits 0 to 9 and the double quote character. They can enter as many digits or quote marks as they like - just not any other characters. Any other character the user may type is ignored. How can I achieve this in the Modern framework. inputMask is NOT what I am looking for. Validators comes close but that just makes the field show as invalid if the user types an invalid character which is annoying for the user.

You can use stripCharsRe.
Here is the documentation link.

Related

XmStringGenerate() in XmMULTIBYTE_TEXT or XmWIDECHAR_TEXT mode

I'm trying to display some Unicode (Cyrillic, actually) using XmLabel and a server-side XLFD font (-monotype-arial-medium-r-normal--*-90-*-*-p-*-iso10646-1). Whenever I use XmStringCreate() or XmStringCreateLtoR() as an XmString factory, the result meets my expectations.
When I try to use XmStringGenerate() factory, however, passing in either XmMULTIBYTE_TEXT for a multi-byte Unicode string, or XmWIDECHAR_TEXT for a wide string, garbage is rendered onto the screen, regardless of the font used (I tried both UTF-8 and single-byte Cyrillic server-side fonts).
The result can be seen below (the 1st 2 lines are ok, 2nd through 6th labels were created with XmStringGenerate() and are obviously not ok):
The complete code (requires Motif 2.1+ and a C99-compliant compiler) is here.
Can anyone suggest a working XmStringGenerate() example suitable for displaying Unicode characters (not just ISO-8859-1)?
XmMULTIBYTE_TEXT is locale-dependent, as n.m suggested, and, aside from CJK (i. e. for Roman and Slavic languages), can only be used in UTF-8 locales. Core X11 fonts can be specified as either fonts (XmFONT_IS_FONT):
-monotype-arial-medium-r-normal--*-90-*-*-p-*-iso10646-1
or font sets (XmFONT_IS_FONTSET):
-monotype-arial-medium-r-normal--*-90-*-*-p-*-*-*:
Speaking of XmWIDECHAR_TEXT mode, it seems impossible to specify a proper font with an explicit encoding, but setting a font set instead works perfectly for Motif 2.1 through 2.3.

Decimal as first character in a number input field

I have a <input type="number"></input> field and when I try to put in a decimal as the first character, it comes up as invalid (I have an ng-change firing).
.5 won't work, but 0.5 is valid. Is there something I can do about this?
Per the HTML spec, .5 is valid for <input type="number">.
So, you’re right, and the tool (browser? Angular?) that validation error’s originating from is wrong.
As far as how to deal with it—how to work around it—I don’t know what to suggest, but as someone who actually works on the specs for this stuff, I would like to ask you to please at least file a bug against whatever tool is (mis)performing the actual validation that’s causing you to see that message. If nobody takes time to report spec-conformance bugs like this (but instead everybody works around it by just putting, e.g., 0.5 to get past it), then the bugs never get fixed.
Anyway as far as evidence for my assertion that .5 is in fact valid: The HTML spec is pretty clear on this; see the section defining what a valid floating-point number is:
A string is a valid floating-point number if it consists of:
Optionally, a U+002D HYPHEN-MINUS character (-).
One or both of the following, in the given order:
A series of one or more ASCII digits.
Both of the following, in the given order:
A single U+002E FULL STOP character (.).
A series of one or more ASCII digits.
Optionally:
Either a U+0065 LATIN SMALL LETTER E character (e) or a U+0045 LATIN CAPITAL LETTER E character (E).
Optionally, a U+002D HYPHEN-MINUS character (-) or U+002B PLUS SIGN character (+).
A series of one or more ASCII digits.
Along with that evidence from the spec itself, here’s a record of other supporting evidence: There was in fact a time when the HTML spec didn’t allow .5 but instead required it to be written as 0.5; however, after a “Floating point numbers beginning with a dot should be valid and parsed correctly” bug was raised against the spec, the spec was subsequently changed (in 2011) to state what it currently states (that is, too allow, e.g., .5).
So, any tool that’s flagging .5 as an error likely has not been updated in this regard since 2011, and so it regardless is in need of its maintainer(s) to go back into their code & evaluate their code against the current spec requirements, to make sure they are conforming to the current spec.
I hope the above provides enough ammunition to use in raising a bug against the responsible tool.
If you want all the input numbers to be valid then you can set in your input field step to "any". It works all integers and decimals numbers. Like -
<input type="number" step="any" />

Unicode/special characters in help_text for Django form?

I am trying to add a special character (specifically the ndash) to a Model field's help_text. I'm using it in the Form output so I tried what seemed intuitive for the HTML:
help_text='2 – 30 characters'
Then I tried:
help_text='2 \2013 30 characters'
Still no luck. Thoughts?
django escapes all html by default. try wrapping your string in mark_safe
You almost had it on your second try. First you need to declare the string as Unicode by prefacing it with a u. Second, you wrote the codepoint wrong. It needs a preface as well; like \u.
help_text=u'2\u201330 characters'
Now it will work and has the added benefit of not polluting the string with HTML character entities. Remember that field value could be used elsewhere, not just in the Form display output. This tip is universal for using Unicode characters in Python.
Further reading:
Unicode literals in Python, which mentions other codepoint prefaces (\x and \U)
PEP263 has simple instructions for using actual raw Unicode characters in a source file.

VXML for DTMF entry of letters based on their placement on dialpad

I'm brand new to VXML (and coding in general) and apparently what I'm trying to do is... not normal, but hopefully it can be done.
I understand the principle concept of DTMF input with VXML where I use:
<grammar mode="dtmf"><![CDATA[ (*|0|1|2|3|4|5|6|7|8|9)<2-31> ]]></grammar>
<prompt>something here</prompt>
<noinput-nomatch-filled>conditions</noinput-nomatch-filled>
What I'm trying to do is take multiple actions to allow DTMF entry of letters based on their placement on the dialpad. You'd achieve this by first dialing the number that the letter is on (2-9), and the placement of that letter (1-4).
For example: "E" would be 3 and 2 on the dialpad.
I'm at a complete loss as to how this would work in VXML. What I'd like to do is this:
1) PROMPT: Please input your THREE letter code. Please enter your first letter.
2) Expect two DTMF inputs the first number between 2 and 9, the second number between 1 and 4. Based on this logic (33 = F, 94 = Z) the letter is set.
3) PROMPT: The letter you have entered is (INPUT). Is this correct? Press 1 for yes, 2 to retry.
4) Retry or go onto the next letter. So on and so forth.
If anyone has resources so I can stumble upon the answer to this myself, that'd be great! If anyone would like a bounty... that's an option, too! Thank you for reading!
The typical approach to this problem is just accept twice the number of tones as you expect or use a pound terminated input. Then use ECMAscript or server side code to translate the tone strings into the desired letters.
There are a couple of a ways to approach this problem:
1) You could just accept all 2 digit numbers in the grammar and do all validation/calculation on the server side.
and/or
2) Do some validation in the <filled> section and letter-decoding-from-number on the server-side (and then come back with the result and check with the user if that was the intended letter).
For the two-digit grammar, you could parameterize the built-in digits grammar as follows (please note that the URI scheme is platform-specific, so you may need to refer to the user manual of your voice browser to be sure of the exact scheme to be used)
<field type="digits?length=2">
<prompt>Please enter the code of the first letter</prompt>
</field>
There are other ways as well, like you could also do letter-decoding on the client-side using a script on the same page, but hopefully the above gives some ideas on what to choose based on your requirement.
(Actually, the OP would probably not be looking for an answer to this question after so long but hopefully it helps others who landed on this page searching for a solution to a similar question)
The best way could be to define a grammar that link each value to the result letter :
<grammar mode="dtmf" root="letter">
<rule id="letter">
<one-of>
<item>32<tag>E</tag></item>
...
</one-of>
</rule>
</grammar>
Another way is to let the user enter the 2 letters and process it with a EcmaScript function, or use the tag .
I am going to plan to add such feature in the Voximal the VoiceXML interpreter for Asterisk.
But are you sure that the users can be able to understand and use this method to enter letters ?

WPF Flowdocument - Prevent line break before % sign

I've got a FlowDocument generating a document for a client, and it's getting a line break that they don't like. Is there any way to mark a section of text that it should avoid line breaks? Something like this:
<Paragraph>Here is a paragraph where there should be <span NoLineBreak=True>no line break</span> in a certain part.</Paragraph>
Obviously, a Span doesn't have a NoLineBreak property, but I'm wondering if there's some equivilant functionality available, or if someone can get me started on a way of implementing a SpanWithNoLineBreak class or RunWithNoLineBreak class?
UPDATE
Actually, one issue I'm having is with a percent sign, where there isn't even a space:
<Paragraph>When I print and ½% I want the one-half and '%' symbols to not line break between them.</Paragraph>
The & #x00BD; is the unicode for a ½ symbol. I'm getting a line wrap between the 1/2 and the % even though there's no space between them.
The Unicode character "Word Joiner" (U+2060) is intended for just this purpose. It "does not normally produce any space but prohibits a line break on either side of it" (Wikipedia). You place it between U+00BD and '%' to prevent a line break between them.
Unfortunately, WPF (or perhaps the typical fonts supplied with Windows) don't support it properly, and instead render it as a square box. As an alternative, you could use U+FEFF; the use of this character as a zero-width non-breaking space is now deprecated (it's reserved for use as a byte-order mark), but it worked as a line-break-preventer for me.
Finally, there are some other characters that can also be used for this purpose: U+202F (narrow no-break space) also prevents breaking, but also renders as a very thin space. U+00A0 (no-break space) prevents breaking and displays as a normal space.
Try replacing the spaces with non-breaking spaces.
EDIT: Well there's always the backup plan of just putting in TextBlocks in your FlowDocument with TextWrapping=NoWrap, but I'd try to find a better way...

Resources