Jquery (js) validation For 10 Digit Mobile Numbers

Jquery (js) validation For 10 Digit Mobile Numbers




After Testing All Answer not getting success . Some times input take alpha character also.
Here is the last full working code With Only number input also keeping in mind backspace button key event for user if something number is incorrect.

html : 

<input name="phone" id="phone" placeholder="Mobile Number" class="form-control" type="number" required>

Js :

<script>
$("#phone").keydown(function(event) {
k=event.which;
if((k>=96 && k<=105) || k==8)
{
     if($(this).val().length==10)
     {
         if(k==8)
         {
             return true;
         }
         else
        {
             event.preventDefault();
             return false;

         }
    }
}
else
{
     event.preventDefault();
     return false;
}

});
</script>
7

Basics Features of Object Oriented Programing Language.


Basics Features of Object Oriented Programing Language.



Features of OOP : -
1.Class
2.Object
3.Inheritance
4.Polymorphism
5.Data Hiding And Encapsuation

Class : - Class is a group of object of same of same type .Once a class has declared we can create multiple numbers of their objects. E.g potato, onion, Cabbage are the object of class vegetables.

Example of Class in JAVA: -

Class Hello //Class hello
{

}



Object : - Objects are collection of entities .Object takes space in memory . Objects are instances of class. When program is executed the object the object interacts by sending message to another . Each object contain data and code to mainpulate the data.

Example of Class and Objects : -

Class Hello //Class hello
{
void run () //Member Function
{
System.out.print(“Hello World”);
}
}
class demo
{
public static void main (String args[])
{
Hello h=new Hello(); // Creating Object of class hello
h.run(); //Calling Method of class hello
}
}

Inheritance : - Inheritance is an Approach through in which object of one class can acquired the property of parents class. Inheritance is used for resuablity of codes.

Example of Inheritance
Class employee
{
int salary=1000;
}
//Extend is used to access the feature and property of parent class

Class developer extends employee
{
int bonus=500;
public static void main(String args[])
{
developer d=new developer();
System.out.println(“Salary is : ”+d.salary);
System.out.println(“Bonus is : ”+d.bonus);
}
}

Polymorphism : - the word polymorphism means many form any operation may exhibite different behaviour in different instance . The behaviour depend on what type of operation we used.
Example :- Function Overloading,Operator Overloading.

Example of Polymorphism

class adding
{
int add(int a,int b) //method one
{
return a+b;
}
// method two same name but differen parameter
int add(int a,int b,int c)
{
return a+b+c;
}
}
class demo
{
public static void main(String args[])
{
adding abc=new adding();
System.out.println(“Sum of 10 , 20 , 30 is : ”+abc.add(10,20,30));
System.out.println(“Sum of 10 , 20 is : ”+abc.add(10,20));
}
}

Data hiding and Encapsulation : - Since wrapping up of data member and menber in a single class is known as encapsulation. Through in which data as are not access by the outside world only member function can access the data this is data hiding. And Also when we hide the complexity of program are known as abstraction . And only essential feature can access. Like when we sending sms we dont what its internal processing we only give inputs.

Example of Encapsulation

class hello
{
int a;
void geta()
{
return a;
}
void seta(String n)
{
this.a=n;
}
}
//hiding the above class and then we only calling the method dont know about the internal processing.
class calling
{
public static void main(String args[])
{
hello h=new hello();
h.seta(“Charles”);
System.out.print(“Name is ”+h.geta());
}
}
13

PHP Captcha Demo


PHP Captcha Demo

PHP captcha




Since we Know Captcha is very Important for our site to prevent our site from misuse or spamming then we will use captcha then attackers or bots not spam in our site.Lets start Creating PHP Captcha for our site.

First : form.php
Code :

<html>
<head>
<title>Check It</title></head>
<body>
<form action="val.php" method="post">
<img src="captcha.php">
</br>
Enter Image Text
<input type="text" name="cap">
</br>
<input type="submit" name="s" value="Submit">
</form>
</body>
</html>

This is simple html form where we print our captcha and input box for captcha value input then we validate its true or false.

Second : captcha.php
Code :

<?php
session_start(); //Starting Session
$code=rand(100000,999999); //Random Number
$_SESSION['code']=$code; //Storing Captcha vallue in session
$im=imagecreatetruecolor(100,40);
$bg=imagecolorallocate($im,80,60,165);
$fg=imagecolorallocate($im,50,255,255);
imagefill($im,5,5,$bg);
imagestring($im,20,30,10,$code,$fg);

//Creating Image in Png fomat

header('content-type:image/png');
imagepng($im);
imagedestroy($im);
//Destroying Image
?>

This is Captcha generating page it generates captcha in png image format and store captcha value in session then we check the session captcha value and user captcha value are same or not.

Third : val.php
Code:

<?php
session_start();
$a=$_POST['cap']; //receiving cap value from form
$b=$_SESSION['code']; //Getting Captcha Value from Session

//Comparing User Captcha value and Session Value
if(isset($a) && $a !="" && $b==$a)
{
echo "correct code enter"; //True Captcha
}
else
{
die ("wrong code entered"); //False Captcha
}
?>

In The Last Page val.php we check captcha is true or false.

Thank You
4