Thursday, 9 April 2015

Email Validation

Now we will see how we can validate our entered form data before submitting it to the web server.
This example shows how to validate an entered email address which means email address must contain at least an @ sign and a dot (.).


<script type="text/javascript">
<!--

Step 1 : 
function validateEmail()
{
 
   var emailID = document.myForm.EMail.value;
   atpos = emailID.indexOf("@");
   dotpos = emailID.lastIndexOf(".");
   if (atpos < 1 || ( dotpos - atpos < 2 )) 
   {
       alert("Please enter correct email ID")
       document.myForm.EMail.focus() ;
       return false;
   }
   return( true );
}

Step 2 : 

var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(email)) {
 alert('Please provide a valid email address');
 return false;
}
//-->
</script>

Saturday, 23 August 2014

Read More option in large content..

If you want to show some content in large content. For that this code will help you...

<?php

function limit_text($text, $limit) 

{

if (str_word_count($text, 0) > $limit) {

$words = str_word_count($text, 2);

$pos = array_keys($words);

$text = substr($text, 0, $pos[$limit]) . '....<a href="" >Read More</a>';

}

return $text;

}

  

$str = "My Name is Karda Ji. I am From India . India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country.";

echo limit_text($str,30); //30 is number after that read more is                                            visible

?>

Wednesday, 20 August 2014

Accepted Extension of File in HTML

Definition:-


The extensions is accepted by the types of files while uploading in form tag.

Note: The accept tag can only be used with file extension.


Syntax:-

<input accept="file_extension|audio/*|video/*|image/*|media_type">

List:- 

Attribute Values

ValueDescription
file_extensionA file extension starting with the STOP character, e.g: .gif, .jpg, .png, .doc
audio/*All sound files are accepted
video/*All video files are accepted
image/*All image files are accepted
media_typeA valid media type, with no parameters.
 Look at IANA Media Types for a complete list of standard media types