Don't allow typing characters like: .,:+ - powershell

I have a Textbox in Powershell and I wondering how to prevent user from typing signs like .,:, key combination like: AAA etc?
I tried with Regex, but I want it to be dynamic - so when user type e.g. . it doesn't appear in TextBox. Probably, the MaskedTextBox can be a solution, but I don't want to specify how many characters user can type e.g. using AA - user can write 2 letters.
My goal is to make typing some signs and letter combination impossible. Do you have any ideas?

Related

Using unaccent with two different rules

German language uses diacritical characters ä, ö, ü. For international use, they are translated into ae, oe, ue (not a, o, u). This mean, that Müller is Mueller on his ID document. This is what we get, when we read the document with (for example) passport reader and this is what we save to the database table.
In next step we search for the records. We do it in two ways:
by entering search data with passport reader (no problem in here)
by entering search data manually
With manual insert there is little problem, because user may enter data international way: 'Mueller' or popular way 'Müller'.
This problem can be solved by using postgres extension Unaccent and modification of unaccent.rules file, so despite is user inserts 'Mueller' or 'Müller', we search in the database for Mueller.
So far so good...
BUT
in the same table we have also other origin's names - for example Turkish ones. Turks translates theirs umlauts (ä, ö, ü) directly into a, o, u, and this way they are saved on the documents, so Müller would by Muller on Turkish document. This causes a problem because (as described before) we search with German unnaccent.rules and we don't find people who we search for.
Long story, but finally question...
... does anybody have any idea how to handle it?
Is there any way, to have two unaccent.rules and use them with or???... for example
Select * from table
where last_name = unaccent('Müller' (use German rules))
or last_name = unaccent('Müller' (use Turkish rules))
(I know that what's above does not work, but maybe there is something similar we could use)
regards
M
The solution should be simple. Define your German unaccent dictionary (I'll call it entumlauten), then query like
SELECT ...,
last_name = unaccent('unaccent', 'Müller') AS might_be_turkish,
last_name = unaccent('entumlauten', 'Müller') AS might_be_german,
FROM tab
WHERE last_name IN (unaccent('unaccent', 'Müller'),
unaccent('entumlauten', 'Müller'))
IN (or (= ANY) will perform better than OR, because it can use an index scan. The additional columns in the SELECT list tell you which condition was matched.
Use soundex() function. This is suitable only for creating lists for human user to pick wanted name. You probably should clean all diacritics (use the Turkish way) before using this.
It also handles similar sounding letters, like C, S and Z or D and T. So Schmidt would match Smith or Jönssen matches Johnson.

Restricting giving numbers or special symbols as form name

I need help in restricting entering form names as numbers in forms flow.
when I am checking I can see that I can enter numbers/special symbols as form name. So I thought it is meaningless if I can enter like that. how can I restrict giving numbers/symbols to form name? can I do it in the form design itself?

Nesting Math Functions in Javascript

I am working on an Acrobat form that should only accept positive, whole numbers in a field.
It is ideal if the number is simply reformated to suit the criteria. For example, if a user types in "-1.4", it should simply change to "1".
Is it acceptable to use this as the "Validation Script" for the field:
if (event.value) event.value = Math.abs(Math.round(event.value));
It seems to work, but is it ok to nest functions like this in general, or will it lead to issues.
Rather than change the value during the validation event, prevent an invalid value from being entered in the first place. To allow only numbers with no dashes to be entered, add the following to the custom keystroke event.
event.rc = !(/[a-zA-Z\-]/.test(event.change));
You may want to modify the regex to prevent other characters as well. I just did the bare minimum. Remember that you'll need to allow for the delete key, return key, and backspace to be permitted so you can't just limit the regex to 0-9 (which would be the obvious thing to do).

T-SQL Procedure parameter name

I have to create a procedure with same parameters names as excel columns. Some loook like this 'xxx/xxx' or 'xxx - xxx'. Is there any work around to name parameteres in a stored procedure like this?
Forward slash (/) or dash (-) are not allowed in variable names
According to http://msdn.microsoft.com/en-us/library/ms175874.aspx, that means that the allowed characters are:
Letters as defined in the Unicode Standard 3.2. The Unicode
definition of letters includes Latin characters from a through z,
from A through Z, and also letter characters from other languages.
Decimal numbers from either Basic Latin or other national scripts.
The at sign (#), dollar sign ($), number sign (#), or underscore (_).
Okay first of all why would you ever want to use special characters? That is like saying I want to fry toast underwater with electricity, why can't I have an outlet to allow that? Special characters denote special things and as such many engines, not just in SQL, but most languages will not allow reserved characters for use in variables. The best you could do was put in parameters with the reversed '_' and then replace that AFTER the object was already created for echoing out. The placeholder name of '#(something)' is really arbitrary and could be #X or #LookAtMe. It's type is important to form a contract that must be fulfilled for execution but the naming is really for hooking up. Having said that if you just must have these weird names echoed out you could do something like this:
CREATE PROC pSimpleParam #My_Param INT
AS
SELECT #My_Param
GO
ALTER PROC pSimpleParam #My_Param INT
AS
SELECT
pr.name AS ParameterName
, REPLACE(pr.name, '_', '-') AS AlteredParameterName
FROM sys.procedures p
INNER JOIN sys.parameters pr ON pr.object_id = p.object_id
AND p.name = 'pSimpleParam'
GO

Word/Publisher email merge issues

I've been searching for days for an answer to this issue. I'm trying to append an Access field to a base URL to customize each email in my merge like so: http://www.example.com/myItems.asp?ItemID={field}.
I tried several approaches in Word 2007, then gave up and finally tried Publisher after coming across this post - MS Word: Mailmerge hyperlinks with query get URL string with a MERGEFIELD.
In Publisher, I got everything to merge properly including the custom links (according to preview), but when I hit "send email" it wasn't passing the emails to Outlook - said 0 message(s) sent. I tried again, using a blank email template and got it to pass the email, but the email showed field names rather than the merged data.
Coming across this article regarding the field names - http://msgroups.net/microsoft.public.publisher/emailmerge-not-working-in-publishe/213664 - I clicked outside the text box as suggested before sending email but still, the field names show and not the merged data.
I'm super frustrated and exhausted. This shouldn't be this difficult! Any ideas or suggestions would be appreciated.
This shouldn't be this difficult!
I agree. I can't help on the Publisher front, but this link should help for Windows Word.
To summarise, when you insert the HYPERLINK field, do it this way:
Use ctrl-F9 to insert a field code brace pair { }
Type HYPERLINK between the braces
Select the field and update it once (F9)
Do not update this field code again. If you do, Word will always insert the same link text (i.e. the hyperlink target). People working with fields often select F9 quite a lot just to make sure things are up to date, so you have to try not to do that.
If you Alt-F9, you should see that the display text is an error message (starting with "E" in the ENglish language version of Word).
Move the insertion point so it is immediately after the E. Type the display text that you want, or, if you want a variable display text built from text + MERGE fields etc, enter that text and those codes).
Carefully remove the "E" and the other part of the error text.
Use ALt-F9 again to display the HYPERLINK field code. Click after the K, type a space, then enter the following fields and text, assuming your variable text is coming from a MERGE field called fieldname:
"{ SET X 1 }http://www.example.com/myitems.asp?ItemID={ MERGEFIELD fieldname }"
(The SET field is there to stop Word doing something else wrong. If you have more than one HYPERLINK field, you will need to SET a different variable name (X1, X2 etc.) in each HYPERLINK). This is discussed in more detail here - interestingly enough, that question was also about merge to HTML email, but I think you also have to do the additional stuff I mention above to make it all work.