Posts

Showing posts from July 31, 2016

Restrict Special Characters in Windows Application using c#

Image
Example : In this application it will remove all the special characters when we trying to copy paste the special characters. Lets see how it is possible with Copy,paste. Please follow these steps : 1. Create a New Windows Form with the name of 'Form1', and take one label with the name of 'lblName' and one textbox with the name of 'txtName' and one button with the name of 'btnValidate'. Please see below image. 2. Add a code in TextChanged event for that textbox. Here my textbox name is 'txtName' in that I have added a event like . private void txtName_TextChanged(object sender, EventArgs e) {       txtName.Text = RemoveSpecialCharacters(txtName.Text); } 3. In that event you observed method name of 'RemoveSpecialCharacters'.Basically it will remove all the special characters when you are copy paste in to the textbox.       private string RemoveSpecialCharacters(String inString)      

Allow Numbers After Decimal And Before In Jquery

Image
Example: In this function it will takes 10 digits before decimal and after decimal it will takes 8 digits. Lets see how it is possible in Javascript, if you want to change it in Jquery also Please follow these steps: 1. Create a textbox with the name of txtDecimal and add a event with the name of onkeypress to that textbox and give maxlength of that textbox. See below. <asp:TextBox ID="txtDecimal" runat="server" MaxLength="20" onkeypress="return CheckNumber(event,this.value)"></asp:TextBox> 2. Create a Javascript function with the name of CheckNumber in aspx page. <script type="text/javascript">         function CheckNumber(key, value) {             var dot= /[.]/g;             var whitespace = /^\S+$/;             var Minus = /[-]/g;             var keyCode = key.keyCode == 0 ? key.charCode : key.keyCode;             var ret = ((keyCode >= 48 && keyCode <= 57) || (keyCode == 45)

Restrict Special Characters Using JavaScript By Copy,Paste

Restrict Special Characters using copy,paste events in JavaScript. Please follow these steps: 1. Create a textbox with the name of txtValidation and add event by the name of onpaste to that textbox. <asp:TextBox ID="txtValidation" runat="server" onpaste="return Validate(this.value);"></asp:TextBox> 2. Create a Function to that event.  <script type="text/javascript">         function Validate(Value) {             var pastedData = window.clipboardData.getData('Text');             var reg = /^[a-zA-Z0-9 ]*$/             if (!reg.test(pastedData)) {                 alert('Not Accept Special Characters');                 return false;             }         }     </script> Some of the special characters are hidden when you copy,paste it will not visible. If you want to restrict those special characters in sql database only, not in application. These Special Characters is not visible whe