General XMetaL Discussion
XMetaL Community Forum › General XMetaL Discussion › Xmetal to check numeric value and alphanumeric value
-
pooh2583 November 23, 2012 at 3:20 am
Xmetal to check numeric value and alphanumeric value
November 23, 2012 at 3:20 amParticipants 3Replies 4Last Activity 10 years, 2 months agoHi,
I am using xft form in which I have to validate whether the string entered in a textbox is a number or not?
I have managed to capture the string I just want to check whether that is a no.(/d) or not using Xmetal Jscript.
and also how to check whether it is an alphanumeric i.e [a-z][A-Z]
Also after capturing the string I want to split it into two parts having different lengths each,
How to get the 2 substring in Xmetal?could you please explain more about this?
Regards
Derek Read November 23, 2012 at 6:52 pm
Reply to: Xmetal to check numeric value and alphanumeric value
November 23, 2012 at 6:52 pmThis isn't really an XMetaL or XFT question, it is more a JScript question (for which there are lots of different answers and resources). There is no “XMetaL JScript”. XMetaL uses the standard JScript engine installed with your copy of Windows, so you can use any of the resources that talk about using JScript on Windows (including Microsoft's documentation), the same engine used by Internet Explorer.
To start, JScript has a function called isNaN() that you can use to check for “non numbers”, however, it is quite simplistic and possibly won't meet your needs. Its main use is to check if something is a number before feeding it into some JScript math expression so that the expression won't fail. However, JScript can convert some things into numbers that you might not expect.
Your best bet is a regular expression. You might start here:
http://msdn.microsoft.com/en-us/library/28hw3sce%28v=vs.80%29.aspx
http://www.w3schools.com/jsref/jsref_obj_regexp.asp
http://stackoverflow.com/questions/18082/validate-numbers-in-javascript-isnumericDerek Read November 23, 2012 at 9:11 pm
Reply to: Xmetal to check numeric value and alphanumeric value
November 23, 2012 at 9:11 pmSorry, I missed the part about substrings. JScript has lots of different string manipulation methods. Here are some you might use by themselves or in combination, depending on what you need to do:
substr()
substring()
indexOf()
lastIndexOf()
slice()
split()
replace()
match()
search()
charAt()The length property might also be useful in some cases.
pooh2583 November 27, 2012 at 10:44 am
Reply to: Xmetal to check numeric value and alphanumeric value
November 27, 2012 at 10:44 amThanks for a reply.
In .xft form I have made use of a Text, which displays text like this
var st1=”ab”;
var st2=”cdh”;
var st3=”ffg”;Text1.Text=st1+”-“+st2+”-“+st3;
and I want to display st2 as bold in xft form in that Text1,
ie
ab-cdh-fgAlso
I have used an EditBox when we enter any character in it ,it is diplayed in the Text.Text on OnChange() event of EditBox
Is there any way to Expand the display size of Text as we enter the characters, and when the length of the string entered in the EditBox cant be entirely seen in Text which displays it.How can I achieve this?
please replyRegards
Derek Read November 28, 2012 at 6:25 am
Reply to: Xmetal to check numeric value and alphanumeric value
November 28, 2012 at 6:25 amI'm not sure I completely understand your bold text requirement but the EditBox doesn't allow you to control how portions of the text inside it appear. For that you will need to use another control. Have a look at Microsoft RichEdit control. You can turn bold/italic/underline and also use colours inside it for different portions as it supports “rich text” (essentially the RTF format).
You should be able to change the size of the EditBox on the fly. How big to make it will be tricky to figure out though, unless you use a fixed-width font. You should be able change the top,bottom,left,right properties to do that. THat seems like it would make for an odd UI though. Perhaps what you should look at in this case is the MultiEditBox control. It supports multiple lines, line wrapping and has a scrollbar.
-
AuthorPosts
- You must be logged in to reply to this topic.