So,
I’ve got a textbox in my website, which is written in c# asp.net 4.
<td>
<asp:TextBox ID="UserName" runat="server" CssClass="textEntry" Width="265px"
placeholder="שם משתמש" ontextchanged="UserName_TextChanged"></asp:TextBox>
</td>
The problem is, that when someone trying to put Hebrew input, it lets him do it.
How can I know that the input he is trying to write is Hebrew and don’t let him? Just like show him a warning in javascript, or just don’t let him.
Anyone can give me a hand?
thanks!
I believe this is what you are looking for:
I don’t have Hebrew on my machine, but I believe it will stop those characters as well
You call this method like so:
Explanation of code:
The “which” variable is the control you are validating. Notice when you call the function, you pass “this”, which loosely translates to “this object”
This tests a regex pattern against the value of the control you passed in
If the pattern matches (meaning there are characters other than a-z), you are alerting the user that they entered invalid characters
Here you are erasing the control’s text. You might not want to do this, depending on your needs.
Here you are putting the cursor back into the control you are validating.
This is used in case you are calling this validation before submitting a form. By returning false, you can cancel the submission of the form.