MVC

  • Home
  • HTML
    • Overview
    • Formatting
  • Java Script
    • Overview
    • Validation
  • CSS
    • Overview
  • Sql
    • Overview
    • SQL Select
    • SQL Command
    • Advance Query
    • SQL Create
    • Function
    • Function vs StoreProcedure
    • Stored Procedures
  • MVC
    • OverView
    • Evolution of MVC
    • Install VisualStudio-2015
    • Create First Application
  • LINQ
    • Introduction
  • Privacy Policy

Saturday, 15 April 2017

Email Validation using Regex Expression in Javascript

  Unknown       14:43       JsValidation       No comments    


  • In This Tutorial I Explain How Validate Email Using Regex Expression.
  • Firstly take textbox in HTML See in Examle.
  • After that Call JavaScript function on text box OnKeyPress.
  • Click on text box and enter Email if Email is not valid then show validation error Message, see above Example

Example
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function EmailValidation(emailField)
{
   var reg = /^\w+([-+.']\w+)*@@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
    if (reg.test(emailField.value) == false)
      {
        document.getElementById("error").style.display = "inline";
       }
    else
      document.getElementById("error").style.display = "none";
 }
</script>
</head>
<body>
<h3>Email validation using Regex Expression</h3>
<table>
  <tr>
    <td>Email </td>
    <td>: </td >
    <td>
      <input onkeypress="EmailValidation(this)" type="text"/>
      <span id="error" style="color:red;display:none">* Invalid Email Id</span>
    </td>
  </tr>
</table>
</body>
</html>
OutPut - 






Mobile no validation using regex javascript


In This Tutorial I Explained How to validate Phone number using regular expression in javascriptsss.
Firstly take textbox in HTML See in Examle.
After that Call JavaScript function on text box OnKeyPress.
If We Enter Mobile No and obile no is not valid then show validation error message using javascript see above example

Example
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function MobileNumValidation(e) {
var reg = /^(7|8|9)\d{9}$/
if (reg.test(e.value) == false) {
document.getElementById("error").style.display = "inline";
}
else
document.getElementById("error").style.display = "none";
} </script>
</head>
<body>
<h2>Mobile Num validation using Regex Expression</h2>
<table>
<tr>
<td>Mobile No
<td>
<td>: </td >
<td>
<input onkeypress="MobileNumValidation(this)" type="text"/>
<span id="error" style="color:red">* Enter valid Mobile Num</span>
</td>
</tr>
</table>
</body>
</html>


Age Validation Using Regex expression in Javascript 

  • In This Tutorial I Explain How Validate only Age in Specific range.
  • Firstly take textbox in HTML See in Examle.
  • After that Call JavaScript function on text box OnKeyPress.
  • Click on text box and enter Age if age not in proper range then show validation error using javascript Regex expression, see above example

Example
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function AgeValidation(AgeField)
{
   var reg = /^([0]?[1-9]{1,2})$/
   if (reg.test(AgeField.value) == false) {
   document.getElementById("error").style.display = "inline";
}
else
  document.getElementById("error").style.display = "none";
}
</script>
</head>
<body>
<h3>Age validation using javascript</h3>
<table>
   <tr>
     <td>Age
     </td>
     <td>: </td >
     <td>
        <input onkeypress="AgeValidation(this)" type="text"/>
        <span id="error" style="color:red;display:none">* Age Should be in between rang 10 to                        99</span>
     </td>
  </tr>
</table>
</body>
</html>
OutPut-

Numeric Validation-Accept Only Numeric value 

  • In This Tutorial I Explain How Validate only numeric value.
  • Firstly take textbox in HTML See in Examle.
  • After that Call JavaScript function on text box OnKeyPress.
  • If We Click on text box then show validation error using javascript see above example.-

Example
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var specialKeys = new Array();
specialKeys.push(8); //Backspace
function IsNumeric(e)
 {
     var keyCode = e.which ? e.which : e.keyCode
     var ret = ((keyCode >= 48 && keyCode <= 57) || specialKeys.indexOf(keyCode) != -1);
     document.getElementById("error").style.display = ret ? "none" : "inline";
     return ret;
}
</script>
</head>
<body>
<h2>Numeric validation using javascript</h2>
<table>
  <tr>
      <td>Employee Salary
      </td>
      <td>: </td >
      <td>
      <input  önkeypress="return IsNumeric(event)" type="text"  />
      <span id="error" style="color:red;display:none">* Input digits (0 - 9) </span>
      </td>
 </tr>
</table>
</body>
</html>
OutPut-

 

 
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
Email This BlogThis! Share to X Share to Facebook
Newer Post Older Post Home

0 comments :

Post a Comment

learningmvctutorial

Popular Posts

  • Overview of HTML
    What is HTML? First developed by Tim Berners-Lee in 1990 . HTML is used to create electronic documents (called pages) that are displ...
  • Overview
      SQL (Structured Query Language)   SQL  is a language that interacts with the database on the server-side. This dynamite duo has changed ...
  • Difference Between function v/s store procedure
    Definition  of Store Procedure In a database management system (DBMS), a  stored procedure  is a set of Structured Query Language (SQL...
  • What is LINQ
    LINQ  (Language Integrated Query) is a Microsoft programming model and methodology that essentially adds formal query capabilities into Mic...
  • What is Function in Sql Server
    A function is a block of code that has a name and it has a property that it is reusable. We use function in store Procedure and queries in...
  • SQL Select
    The SQL SELECT Statement The SELECT statement is used to select data from a database. SQL SELECT Syntax SELECT column_name , column_n...
  • About Javascript
    What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting langua...
  • Create Duplicate Table of existing table in SQL Server
    In This Tutorial we create table and want to same structure and same data then We create new table with data type after that  insert in ta...
  • Operator in JavaScript
    What is an operator? JavaScript has both binary and unary operators, and one special ternary operator, the conditional operator. A binar...
  • Create First Application in MVC
    We want to create Firstly application in MVC first of how we create first application Show Steps   as below-     STEP 1 .  Start Computer ...

Blog Archive

  • ▼  2017 ( 35 )
    • ►  November ( 1 )
    • ►  October ( 2 )
    • ►  September ( 4 )
    • ►  August ( 1 )
    • ►  July ( 1 )
    • ►  May ( 3 )
    • ▼  April ( 7 )
      • Fetch Unique random Record in sql server
      • Operator in JavaScript
      • Conditional Statements in JavaScript
      • Create Duplicate Table of existing table in SQL Se...
      • Email Validation using Regex Expression in Javascript
      • About Javascript
      • Advantage and Disadvantage of LINQ
    • ►  March ( 13 )
    • ►  February ( 3 )
Powered by Blogger.

Categories

  • AdvanceQuery
  • CreateApplication
  • CreateDb
  • CssOverview
  • Evolution
  • Formatting
  • Function
  • FunctionVSSp
  • HtmlOverview
  • InstallVisualStudio
  • Introduction
  • javascriptOverview
  • JsValidation
  • Mvc-vs-Asp.Net
  • OverView
  • Select
  • SqlCommand
  • SQLOverview
  • StoredProcedures

Text Widget

Sample Text

Pages

  • Home

Copyright © MVC | Powered by Blogger
Design by Vibha Acharya