Wednesday 26 June 2013

Handling the radio button list with yes or no confirmation message in C#


rdbbilltype.Attributes.Add("onclick", "if(!confirm('Are you sure to change the bill type? ')) return false;");



Looks simple but it will allow only when the OK button is clicked, Or else it wont change the selection.

Awesome...!!!

Monday 17 June 2013

Javascript validation for special characters in ASP.NET/ C#

function validatespecailchars()
{

     var txtbox = document.getElementById('<%=txtsearch.ClientID %>').value;
   
      var str="<";
        var str1=">";
        var str2="--";
        var str3=";";
        var str4="'";

    if((txtbox.indexOf(str)>=0)||(txtbox.indexOf(str1)>=0)||(txtbox.indexOf(str2)>=0)||      (txtbox.indexOf(str3)>=0)||(txtbox.indexOf(str4)>=0))
    {
         alert('Special Characters are not Allowed.');
        // you can focus here that particular control
     }
}