Subscribe For Free Updates!

We'll not spam mate! We promise.

Aug 25, 2013

Email validation using JavaScript and Jquery

Email validation using JavaScript and Jquery :

Email validation in Jquery - TechniqZone

 Here i will explain how to validate email id with JQuery. In JavaScript we can check the email id format only. but in jquery we can check whether we allow or not some of domain names also. First i will explain basic javascript method to validate email id.

Here is Javascript method :

function validateEmail(emailId)
{
var condition = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
return condition.test(emailId);
}
In this javascript method only validate the given email id has alphabets and numeric. Here the variable "condition" has the email conditions. that is

([a-zA-Z0-9_.+-]) - is to allow email id username with  alphabets and numeric and also _.
@(([a-zA-Z0-9-]) - is to allow domail name with alphabets and numeric . and
([a-zA-Z0-9]{2,4}) - is to allow last part of the email id i.e., com, in, .. with alphabets and numeric and also                                   it's length should be 2 to 4.

Now i will explain how to validate email id with JQuery.

Here is JQuery Method :

$(document).ready(function() {

  $('#submitButton').click(function() {

    var emailCon = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
    var emailblockCon =/^([\w-\.]+@(?!gmail.com)(?!yahoo.com)([\w-]+\.)+[\w-]{2,4})?$/;

    var emailId = $("#mailId").val();
    if(emailId == '') {
      $("#mailId").val('Email id is Blank.');
      error = true
    }

    else if(!emailCon.test(emailId)) {
      $("#mailId").val('Check Your Email id.');
      error = true
    }

    else if(!emailblockCon.test(emailId)) {
      $("#mailId").val('gmail and yahoo mail ids not accept.');
      error = true
    }

    if(error == true) {
           return false;
    }

    });
}); 

In this JQuery method you can check the email format like in javascript . In jquery we validate extra one condition. here we validate the email id domain name also. because some of the website doesnt allow some free email providers domain. so we can also validate it here.


Aug 19, 2013

PHP - Validate Email Id


PHP - Validate Email Id :

 Here i will explain how to validate email id in php. This is very use full to validate email id in server side. php is used in server so we can validate email id in server side. if you want to validate email id in client side then you can use JavaScript, jquery etc...

 The below example will show you how to validate email id in PHP

Example :
<?php

$mailId = "xxx@gmail.com"; // Valid email
$conditions = '/^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([comco.in])+$/';
if (preg_match($conditions, $mailId))
{
echo "Valid Mail Id";
}
else
{
echo "Invalid Mail Id";
}

?&gt;





 In the above example "$mailId" having the email id given by user. and "$conditions" having conditions for validate given email id. here i used "preg_match()" predefined php function. this function return boolean value. if the match occurred then it will return true otherwise false.

 The above example print "Valid Mail Id". Here the variable "$conditions" have "com","co","in" conditions only, so it will allow these extension mail id only. and it will validate all allowed special characters only.

 if A$mailId="xxx@gmailo.comnm" then the output is "Invalid Mail Id".

Aug 14, 2013

Create directory with current year and month name - php

Create directory with current year and month name - php :
 

  Here i will explain about how to create folder / directory with the current year and month name. It is very usefull to seperate the uploaded image or file with the particular year and month name.

Here we will use the simple concept to create this. here date() function is used to get current year and month details.

For Example :

  if (!file_exists("techniq/".date('Y').'/'.date('m'))) {
    mkdir("techniq/".date('Y').'/'.date('m'), 0777, true);
   }

  In the above example three php pre defined function are used. that is file_exists() , date() , mkdir().

1. file_exists() :- This function is used to check the given path for directory is available or not. It will return bool value. If the file exists then it will return TRUE otherwise FALSE.

2. date() :- This function is used to get current timestamp. here i used date('Y'), it will return current year in numeric i.e., 2013. and date('m') return current month in the format of 08.

   Note : Read more about date() : http://techniqzone.blogspot.in/2013/07/php-to-get-yesterdayprevious-date.html

3. mkdir() :- This function is used to create a directory with the give filename or path. here i used 0777 argument for set folder permission for the created directory.

This method is easy to create Folder(directory) with current Year and Month name in php.

Aug 13, 2013

Export particular column data from table in phpmyadmin


Export particular column data from table in phpmyadmin :

 Here i will explain how to export particular column data from table. we can store the output in .sql or .csv file. In this method the output data will store in a file with newline (\n) separaters.

The syntax is :

SELECT column_name FROM table_name INTO OUTFILE '/opt/lampp/htdocs/fileName.sql'

The above syntax is store the output file in .sql format. you can change the format what you need. In the below example i will make the ooutput file in .csv format.

Example :

SELECT second_name FROM employee INTO OUTFILE '/opt/lampp/htdocs/secondName.csv'

Note : Best to download output file with .csv format. because .csv file format import has many advanced option when we import data to db. you can export with CSV, .zip, .gzip, etc... format.