Rai Yawar Ijaz

blog

  Home  |   Contact  |   Syndication    |   Login
  6 Posts | 3 Stories | 11 Comments | 34 Trackbacks

News

Article Categories

Archives

Post Categories

Friday, November 12, 2004 #

there was seminar on 4th of november on CMS . I will inshallah put the slides here soon .

 


var mydata=document.SignUP.txtZip.value;//here the name of the form is “SignUp” and name of the text field on which i want to enforce numerical characters is “txtZip“

 for(var i=0;i < mydata.length;i++)

 {

               var mydigit = mydata.charAt(i);

               if(mydigit < "0" || mydigit > "9")

                          {

                                   alert('Please Enter a Numeric value');

                                    document.SignUP.txtZip.focus();

                                    return false;

                            }

 }


I just have notices that you can't access hyperlink as usually you access other serverside controls.

Suppose there is a Server side TextBox named “txtBox”

you will Access it in javaScript as

[document_name].[form_name].[Control_name].value

document.form.txtBox.value

here is assume that the name of my Server Side Text box is “txtBox“ and the name of my Form is “form“

okie this is the normal procedure . you can't Access Server Side in the same fashion. As it is rendered as  <a> in the HTML so u have to send the function with the clientID parameter when want to access a hyperlink

your Code behind Code

Form_Load()

{

[ControlName].Attributes.Add(“OnClick“,“validate(“ + [ControlName].ClientID + “)“);

}

your Scripted Code

<script>

function validate(clientID)

{

var control=document.form.getElementById(clientid);

var.href=“ure specified url“ // or wat ever u want to do .

}

</script>

if you experience any problem in using the CODE just write me a mail on raiyawar@gmail.com

 

 


function validateEmail(strEmail)

{

 

             var at="@"

             var dot="."

              var lat=strEmail.indexOf(at)

              var lstr=strEmail.length var

             ldot=strEmail.indexOf(dot)

             if (strEmail.indexOf(at)==-1)

             {

                       alert("Invalid E-mail ID")

                        return false

                }

              if (strEmail.indexOf(at)==-1 || strEmail.indexOf(at)==0 || strEmail.indexOf(at)==lstr)

             {

                 alert("Invalid E-mail ID")

                return false

                }

             if (strEmail.indexOf(dot)==-1 || str.indexOf(dot)==0 || strEmail.indexOf(dot)==lstr)

              {

                       alert("Invalid E-mail ID")

                          return false

                  }

                if (strEmail.indexOf(at,(lat+1))!=-1)

              {

                        alert("Invalid E-mail ID")

                        return false

                  }

             if (strEmail.substring(lat-1,lat)==dot || strEmail.substring(lat+1,lat+2)==dot)

            {

                    alert("Invalid E-mail ID")

                   return false

               }

          if (strEmail.indexOf(dot,(lat+2))==-1)

                    {

                            alert("Invalid E-mail ID")

                             return false

                    }

                if (strEmail.indexOf(" ")!=-1)

         {

                 alert("Invalid E-mail ID")

                   return false

              }

        return true

 }