Regular expression to match case insensitive string - regex

We have a form in our website where at the very end the user has to type "SIGNED BY ME, [Name of the User]" in a text box before he or she can submit it. It is part of the requirement where the users has to digitally sign the form. The validation code for the text box is below:
<input type="text" placeholder="SIGNED BY ME, YOUR NAME" maxlength="500" value="" id="agreedment2_agreed_sign" name="agreedment2_agreed_sign" data-val="true" data-val-required="Please sign in the box" data-val-regex="SIGNED BY ME, #Model.Fullname.ToUpper()" data-val-regex-pattern="^signed by me, #Model.Fullname.ToLower()|SIGNED BY ME, #Model.Fullname.ToUpper()$">
<span class="field-validation-valid" data-valmsg-for="agreedment2_agreed_sign" data-valmsg-replace="true"></span>
The jquery validation works fine if the user (say, John Smith) enters the text as "SIGNED BY ME, JOHN SMITH" or "signed by me, john smith". But it doesn't work if the user enters mixed case like "Signed by me, John Smith". I have tried adding modifier "/i" to the regex pattern which didn't work. I also tried adding data-val-regex-insensitive="true" to the input. It didn't work either.
Any suggestion, how I can achieve it.

Related

cfinput not accepting .education domain names

For the first time ever I had two users come into my app with a .education top level domain. Their email address looked like this: user#domain.education. I'm using the cfinput validate attribute on the form they are filling out as follows:
<cfinput type="text" name="email" required="yes" message="Please enter a valid email address." validate="email">
When the users submits the form they are getting my error message. The form has been working successfully for years on all the other email addresses entered. Are there any tricks to make it take this top level domain? TIA
Avoid all of the ColdFusion UI tags. They will only cause pain.
Each version of ColdFusion updates the built-in email validation to handle the new top-level domains (TLD) of the time. There are nearly 1600 active TLDs at the moment.
Javascript validation isn't going to cut it.
Regular expressions won't either.
You will need to validate on the server if you aren't already.
Better you remove that validation rule for a start and send an email to verify the email account exists before activating the user on your app.
I agree with the other answers about limiting your use of cfinput, but as a quick fix you should be able to use the cfinput PATTERN attribute (https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-i/cfinput.html):
<cfinput type="text" name="email" required="yes" message="Please enter a valid email address." validate="regex" pattern="(?:[a-z0-9!##$%&'+/=?^_{|}~-]+(?:\.[a-z0-9!##$%&'*+/=?^_{|}~-]+)|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\[\x01-\x09\x0b\x0c\x0e-\x7f])")#(?:(?:a-z0-9?.)+a-z0-9?|[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-][a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\[\x01-\x09\x0b\x0c\x0e-\x7f])+)])">
The PATTERN attribute can be changed to any regular expression. The one provided is RFC 5322 compliant.
EDIT: Changed pattern to Java based RegEx and escaped #'s

Regex Text Input Validation

I'm way in over my head here, but trying to learn.
Attempting to use text input validation on Cognito forms by way of a custom regular expression.
I'm trying to capture users work email in an online form. In the "work email" field they would only be able to enter the text to the left of the # and then once they type "#" it'll automatically populates the "organization.com." I'll probably want to make sure that the user cant enter spaces, and other characters (ie:'*&^%$#!)
Been googling how to do this but no luck so far. I'm sure I'm using the wrong terminology to describe what i'm trying to accomplish.
This does everything you need except handle the actual submission of the data.
document.querySelector('input').oninput = function () {
if (this.value.endsWith('#')) {
this.value += 'organization.com';
}
}
<form>
<input type=email pattern=.*#organization\.com$ title='name#organization.com' required />
<button type=submit>Submit</button>
</form>

Primeng KeyFilter not working well

i am using KeyFilter Module of primeng here is my code :
<input type="text" pInputText [(ngModel)]="price.TintCost" [pKeyFilter]="patternDecimal" name="tintCost" required="true" />
here is my typescrip code :
patternDecimal: RegExp = /^[0-9]+(\.[0-9]{1,2})?$/;
and here is version of primeng :|
"primeng": "^5.2.0-rc.1",
i tested in regex then i can type dot(.) but when i apply to KeyFilter, it doesn't allow the dot(.). Someone help me, please
I solved this problem by adding a mask as default
KeyFilter.DEFAULT_MASKS['currencyRegex'] = /^-?(?:0|[1-9]\d{0,2}(?:,?\d{3})*)(?:\.\d+)?$/;
I solved this problem by change the pValidateOnly property to true.
The problem is that the KeyFilter check any press on keyboard and if the complete value is no the correct, then dont permit write, just if you copy and paste the value.
In the documentation say
Instead of blocking a single keypress, the alternative validation mode
which is enabled with pValidateOnly property validates the whole input
with a built-in Angular validator.
https://www.primefaces.org/primeng-6.1.6/#/keyfilter
Example that work for me.
Component.ts
public twoDecimal: RegExp = /^\s*-?(\d+(\.\d{1,2})?|\.\d{1,2})\s*$/
Component.html
<input name="decimalField"
#decimalField="ngModel"
[pKeyFilter]="twoDecimal"
[pValidateOnly]="true"
[(ngModel)]="item.decimalField"
type="text" pInputText>
<div *ngIf="!decimalField.valid" class="alert alert-danger">
<p>Incorrect format.</p>
</div>
The answer of #Norberto Quesada is correct.
Without pValidateOnly the regex will validate on every key stroke.
Let's say you want to enter the value "47.11":
You begin to enter "4" => this would be valid, no input blocked.
Same for "47"
As soon as you enter "47. => validation fails, input blocked.
I was thinking maybe it's possible to enter "4711" first and then the "." in between but for some reason this doesn't seem to work, too... Maybe this is a bug?
Anyways, you can take a look at this stackblitz example for better understanding.
I've also prepared an example of using ValidateOnly and in addition to that restrict the input to only numbers using keyDown event

a href attribute for Skype chat

I am trying to create an a tag leading to Skype chat.
The problem is that Skype did not give me an ID. People find me only using my first and last name.
I tried this but it didn't work.
<a href="skype:John Doe?chat">
see the null space? John &nbsp Doe.
How can I type it so it works properly?
E.g: I do not want to use my phone number.
Thank you
The values need to be escaped. <a href="skype:John%20Doe?chat">
Alright so I found a workaround.
I added myself from a new account to see what is my Id.
It has this form live:b3e263c856585e34 .
So I used this <a href="skype:live:b3e263c856585e34?chat"> and it worked fine.
Strange but it works

How do I use a custom Tooltip Text for Invalid Input Pattern instead of "You must use this format: [blank]"

When the input does not match the pattern specified by the pattern attribute, Firefox simply says, "Please match the requested format", which is okay; however, when this validation fails Internet Explorer 10 displays "You must use this format:" in a tooltip with nothing else. This may be simple, but searching has not yielded me a clue as to how to supply text to the tooltip telling it the pattern that should be used.
Example below for a one to four digit number:
<input id="institution_threshold_days" type="text" placeholder="0-9999" pattern="^[0-9]{1,4}$" />
Try using the title attribute to describe what you want it to say:
<input id="institution_threshold_days" type="text" placeholder="0-9999" pattern="^[0-9]{1,4}$" title="Please enter a number less than 10000." />
Should work for all major browsers...
From Microsoft
the content of the title attribute is both shown as tooltip text for
the field and appended to the generic pattern mismatch error message.
From Mozilla
Use the title attribute to describe the pattern to help the
user.
And although I cannot find official documentation, it appears to work in Chrome as well.