ASP.NET - restriction in textbox control

Asked By vadivu eagaraja
03-Feb-12 05:28 AM

Hi All,

  How to restrict those special characters (\,{,}) within javascript like

keychar == ";"

Help me to solve
thanks,
vadivukarasi

  kalpana aparnathi replied to vadivu eagaraja
03-Feb-12 05:37 AM
hi,

Try this way:

<script language="javascript" type="text/javascript"
function check(e) { 
var keynum 
var keychar 
var numcheck 
// For Internet Explorer 
if (window.event) 
keynum = e.keyCode 
// For Netscape/Firefox/Opera 
else if (e.which) 
keynum = e.which 
keychar = String.fromCharCode(keynum) 
//List of special characters you want to restrict 
if (keychar == "'" || keychar == "`"
   
return false
else
return true
</script>
  vadivu eagaraja replied to kalpana aparnathi
03-Feb-12 05:39 AM
the same code already implemented

i want to include this symbols to be restricted in the above code   
   \  {  }
  kalpana aparnathi replied to vadivu eagaraja
03-Feb-12 05:47 AM
hi,

ok fine if you want to another idea for it so please use jquery.

Thanks,


  kalpana aparnathi replied to vadivu eagaraja
03-Feb-12 05:53 AM
one solution use this regular expression ^[-_,A-Za-z0-9]$

Hope will work !!

Thanks,

  Ahi I replied to vadivu eagaraja
03-Feb-12 06:27 AM
Hi  vadivu eagaraja  its working fine in all browsers.... 

Here i marked allowed events... here u can change ur keycodes....

function alpha_number(myfield, e, dec)
{
var key;
var keychar;


if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);


// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;


// numbers
else if ((("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .()&!@#$%^*_+=-|[];',./").indexOf(keychar) > -1))
   return true;


// decimal point jump
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}



onkeypress="return alpha_number(this,event)"

  vadivu eagaraja replied to Ahi I
03-Feb-12 06:31 AM
thanks ahi  
  Somesh Yadav replied to vadivu eagaraja
03-Feb-12 06:43 AM
hi go through this link

http://www.scriptingmaster.com/javascript/using-escape-codes-sequence.asp
  Ahi I replied to vadivu eagaraja
03-Feb-12 07:24 AM
U r always welcome vadivu...
Create New Account
help
Net hi friends Any one send frequently asked Important questions in C# .Net, ADO .Net, Asp .Net and Sql Server. . . . . . . . tx in Advance. . . . . . Hi, Find this. . (B)What is an IL? (B A) What is scavenging? (B) What are different types of caching using cache object of ASP.NET? (B) How can you cache different version of same page using ASP.NET cache object? (A) How will implement Page Fragment Caching? (B) Can you compare ASP.NET sessions with classic ASP? (B) Which are the various modes of storing ASP.NET session
in Sql server as var_name int How do you separate business logic while creating an ASP.NET application? There are two level of asp.net debugging 1. Page level debugging For this we have to edit the page level debugging The control itself will take care of the date display How can you deploy an asp.net application ? You can deploy an ASP.NET Web application using any one of the following three deployment options. a) Deployment using VS
Migration from ASP to ASP.net How to convert ASP site to ASP.NET site using C# http: / / www.asp.net / downloads / archived-v11 / migration-assistants / asp-to-aspnet hi, ASP.NET framework is very much different from unstrucured ASP and there is no correct way to
Tracing in ASP.NET? hi all, what is tracing? how to achieve tracing in asp.net? different ways of doing tracing? thanks and regards Aman Khan hi. . Tracing in ASP.NET 2.0 Tracing is a way to monitor the execution of your ASP.NET application. You can record exception details and program flow in a way that doesn't
session is user based mean u can differentiate login user in different way • Process independent. ASP.NET session state is able to run in a separate process from the ASP.NET host process. If session state is in a separate process, the ASP.NET process can come and go while the session state process remains available. Of course, you ASP, too. • Support for server farm configurations. By moving to an out-of-process model, ASP.NET also solves the server farm problem. The new out-of-process model allows all servers