6/17/2018

Email and Form Validation Using Javascript With Example

We will validate an Email and Form using Javascript, We will learn in a simple ways make Email validation is very simple by taking simple easy steps same steps you can follow for Form validation using JavaScript. Let's find the solution to "How to validate an email address using Javascript". First, we will solve an Email verification problem after that we move to second and most important problem Form validation using Javascript so don't worry just follow the steps and read this article carefully, I make sure to clear your all doubt's. Lets first understand the how client and server communicate each other. After the end of this post try to design a nice student registration form using HTML, CSS, and Javascript. Student registration form in HTML with javascript validation

This is the architecture with the help of which we communicate daily through the internet. And there are two types of scripting languages

(1) Client-Side Scripting language 
(2) Server-side Scripting language.

๐ŸŒŸ๐ŸŒŸFree Download Web Designing Projects Visit: Web Designing and Web Developing

And that is what client-side scripting language is JavaScript, JavaScript communicates server side asynchronously. Basically server-side scripting language is for connecting to the database and getting data from DB(Database) according to the request.

Client Server Communication in Email and Form Validation in Javascript

JavaScript is a high level, un-typed and interpreted programming. JavaScript is platform independent. Both Java and JavaScript are Different things other than some naming and standard. JavaScript is a lightweight language used to design web applications. We need HTML and CSS to design the web pages and JavaScript is used to add functionality, validation form, communicating with the server and Read-Write HTML elements. JavaScript is a client-side scripting language. Communicating with the server is done by using AJAX. When we run JavaScript code on the browser and when browser come to know that JavaScript code is there then interpreter starts its working, Interpreter come equipped with browsers. And How browser come to know that JavaScript code is there, Because of our <Script> </Script> tag in the code.

There are two ways to embedding JavaScript with HTML:

(i) Inside HTML file or 
(ii) Create a .js file of JavaScript code and connect it to HTML. 

Starting with JavaScript I am going to use Notepad++ for validating Email address textbox using JavaScript.

#Using JavaScript inside HTML using <Script> </Script> Tag.

<!DOCTYPE html>
<html lang="en">
<head>
      <meta charset="utf-8">
      <title> Hello </title>
                            <script type="text/javascript">
                                document.write("Hello World");
                          </script>
    </head>
    <body>
    </body>
  </html>

#Using JavaScript in the External file:

Script tag will not be there in the .js file, we will add this tag in HTML file with a “source attribute”: Create a hello.js file and write the code  in the file:

document.write("Hello World");

And write the code in HTML file for Javascript Email validation:

<!DOCTYPE html>
<html lang="en">
<head>
      <meta charset="utf-8">
      <title> Hello </title>
          <script language="javascript" type="text/javascript" src="hello.js"></script>
<body>
   </body>
</head>
</html>


Programs for validating an Email Using Javascript:

1) Email Validation Using JavaScript With Output


<!DOCTYPE html>
<html>
     <head>
           <title> Email Validation </title>
                 <script type="text/javascript">
                              function validation(event)
                                  {
                                    event & event.preventDefault();
                                    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
                                    var emailVal = document.forms["testForm"]["emailInput"].value;
                                    console.log(emailVal);
                                    if (reg.test(emailVal) == false)
                                     {
                                         alert('Invalid Email Address');
                                         return false;
                                        }
                                  alert('Valid Email Address');
                                  return true;
                            }
     </script>
</head>

<body>
       <form name="testForm" onSubmit="return validation(event)">
       <label> Email </label>
        &nbsp;&nbsp;
       <input type="text" name="emailInput" required/>
       <br />
             <button>Submit</button>
  </form>
</body>
</html>

Output:
form validation using javascript output

2) Form Validation Using Javascript With Source Code and Output


<!DOCTYPE html>
<html>
<head>
            <title> Email Validation </title>
              <script type="text/javascript">
                function validation(event)
                 {
                event & event.preventDefault();
                 var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
                 var emailVal = document.forms["testForm"]["emailInput"].value;
                var contact = document.forms["testForm"]["contact"].value;
                var pwd = document.forms["testForm"]["pwd"].value;
                var confirmPwd = document.forms["testForm"]["confirmPwd"].value;
                if (reg.test(emailVal) == false)
                   {
                     alert('Invalid Email Address');
                     return false;
                  }
                 if (contact.length != 10)
                  {
                   alert('Your Contact No. should have 10 Digits');
                  return false;
                    }
                 if (pwd != confirmPwd)
                    {
                    alert('Password Should match in both fields');
                    return false;
                   }
              return true;
           }
</script>
</head>
<body>
<form name="testForm" onSubmit="return validation(event)">
<label for="fullName">Full Name </label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="fullName" placeholder="Full Name" required/>
<br/><br/>
<label for="emailInput"> Email </label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="emailInput" placeholder="Email Address"  required/>
<br/><br/>
<label for="contact"> Contact No. </label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="number" name="contact" placeholder="10 digit Phone No."  required/>
<br/><br/>
<label for="pwd"> Password </label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="pwd" placeholder="Password"  required/>
<br/><br/>
<label for="confirmPwd"> Confirm Password </label>
&nbsp;&nbsp;&nbsp;
<input type="text" name="confirmPwd" placeholder="Password"  required/>
<br/><br/>
<button>Submit</button>
</form>
</body>
</html>

Output:


simple email validation in javascript output

Conclusion: So we learn in this post Validating form using JavaScript or Email Validation Using JavaScript or JavaScript form validation through the internal and external file in a simple way. This program is a demo for validating an Email and Form using HTML and JavaScript.

Author: This Javascript tutorial for an Email and Form validation is provided by Suman Yadav. Thanks, Suman for the Awesome and Unique article. If you want to submit your article and want to be a member of our ProgrammingWithBasics Family Join us by sending a well-written article more information read Write for Us

Read More »

6/15/2018

Best Institute to Learn German in Bangalore

Learn How S V Videsh Vidya become No. 1 or Best Institute to Learn German in Bangalore. Instruction specialists in Bangalore can encourage guardians and understudies design their future instructive a correct way. SV Videsh Vidya is also providing a good opportunity for study abroad for Indian Student. They are viewed as master Consultants, who have to learn reasonably for forming one's training in order to have a fruitful profession and brilliant future. There is a major area where SV Videsh Vidya is in top Position in Karnataka India area's are  Study Overseas consultants & Training Institute MBBS| GRE | German. Their zone unit differed types of instructional advisors two or three specialists zone unit generalists, though most normally center around furnishing substance and directing understudies with particular necessities. We are going to Discuss topics following in this post.

IELTS Coaching in Bangalore for German


Table of Content


1. What is S V Videsh Vidya
2. What are The Best Institutes to Learn German in Bangalore?
3. German Language Scope
4. Level for Learning German Language
5. Study Abroad | Study Overseas consultants & Training Institute MBBS| GRE | German
6. Conclusion

Best Institute to Learn German in Bangalore

Image Credit: SVVideshVidya

1. What is SV Videsh Vidya


S V Videsh Vidya Enterprises was established in 2014 by Veena B Revashetti. Since then it has evolved into one of the emerging Study Abroad Consultants in Bangalore. We offer students an excellent opportunity to explore educational opportunities around the world. Our expertise in career guidance helps us understand student’s interests and we counsel them in the right direction to ensure that every student chooses the right country and subject catering to their needs.

2. What are The Best Institutes to Learn German in Bangalore?


Your best look for Higher Education Consultants closes here at S V Videsh Vidya. We direct understudies, who pick the most proper remote foundations and courses which help the understudy according to your requirements and they have best Planning to consider for advanced education or searching for profession direction.

3. German Language Scope


The German Language is a major brand and furthermore part of the advanced education along these lines, on the off chance that you are searching for the Best German Classes in Bangalore at reasonable, at that point proceed with S V Videsh Vidya. They are putting forth extraordinary compared to other German classes as you need.

4. Level for Learning German Language


German dialect is isolated into 6 levels for universal understudies according to Common European Framework of Reference for Languages (CEFR). It begins with:

A1 Level
A2 Level
B1 Level
B2 Level
C1 Level
C2 Level

For More Details Infromation Please Visit: S V Videsh Vidya Level for Learning German Language

5. Study Abroad | Study Overseas consultants & Training Institute MBBS| GRE | German


S V Videsh Vidya has propelled special examination Abroad stage choices and your pursuit will be closed here at the therapeutic course in China encourage you.

India is a charming nation for seeking after MBBS for Indian understudy. Be that as it may, just around 2% of understudies get government seats. Last understudies who are sharp in seeking after a clinical scan for different options like seats intuition based schools. a couple of understudies who can figure out how to pay for are fortunate and satisfy their desire in transforming into medicinal specialists by seeking after therapeutic tutoring in individual schools.

at that point the last undergrad's post for various choices in other global areas inside their financial plan in nations like south the assembled states, Europe, China, Ukraine, Russia and the UK 

MBBS in China is one of the favored choices as a result of the minimal effort, great training framework, no passageway test, Medium of Instruction is English and numerous have MCI endorsed universities. Out of these 45, MCI endorsed schools we can offer confirmation in view of understudies qualification, accessibility and with their financial plan. MBBS program in China at the best restorative school in China is extraordinarily intended to suit to the necessities of global understudies. You can discover the rundown of MCI endorsed restorative

6. Conclusion

Did you know? After you seek after your lords/unhitched males in a European country, it's potential for you to win on the perspective. Universal understudies are permitted to figure up to four months all through their Bachelor and Master courses.

Individuals need an expert instruction in the least time for a developing vocation for being close to home, so these are completely befuddled and thinks how to begin proficient training with the right way and confided in the rule, so Sv Videsh Vidya ensure a right way for you.

The last very experts are the individuals who encourage generally prepared understudies and their people. As there square measure just a couple of foundations around the nation United Nations office focuses on teaching unfit or crippled understudies.

Tags: ielts syllabus, ielts institute in bangalore, best ielts training in bangalore, ielts coaching bangalore, the ielts academy bengaluru karnataka, german embassy in bangalore, german learning classes in bangalore, direct mbbs admission in karnataka, ielts coaching center in bangalore, abroad study consultants in bangalore, ielts coaching center in bangalore, mbbs admission consultants in bangalore, ielts coaching centers in bangalore near electronic city, ielts coaching in electronic city, ielts coaching in rt nagar bangalore, ielts coaching in koramangala bangalore, best german classes in bangalore, ielts coaching center in bangalore, mbbs in abroad
Read More »

3/02/2018

Day 23 BST Level Order Traversal HackerRank Solution In C++

Problem:- Day 23 BST Level-Order Traversal hackerRank or Hackerrank: Day 23: BST Level-Order Traversal or binary search tree insertion hackerrank solution or Day 23 BST(binary search tree) Level order traversal hackerrank solution or hackerrank Day 23 BST(binary search tree) Level order traversal solution or hackerrank solution Day 23 BST(binary search tree) Level order traversal solution or hackerrank Day 23 BST Level order traversal solution or hackerrank solution BST Level order traversal solution or hackerrank solution binary search tree Level order traversal solution or (bst) binary search tree Level order traversal solution or hackerrank binary search tree Level order traversal solution.

1. What is a binary search tree(BST)?
2. Binary search tree time complexity

Now explain both queries with a full explanation. so let's see what is Binary Search Tree(BST).

1. What is a Binary Search Tree(BST)

Binary search trees (BST), sometimes called ordered or sorted binary trees, are a particular type of container: data structures that store "items" (such as numbers, names etc.).

binary search tree
credit: Wikipedia

Binary search trees keep their keys in sorted order, so that lookup and other operations can use the principle of binary search: when looking for a key in a tree (or a place to insert a new key), they traverse the tree from root to leaf, making comparisons to keys stored in the nodes of the tree and deciding, on the basis of the comparison, to continue searching in the left or right subtrees. On average, this means that each comparison allows the operations to skip about half of the tree so that each lookup, insertion or deletion takes time proportional to the logarithm of the number of items stored in the tree.

2. Binary search tree time complexity

Algorithm Average     Worst case
Space O(n)         O(n)
Search O(log n)         O(n)
Insert O(log n)         O(n)
Delete O(log n)         O(n)

Read complete article on Wikipedia

Task:- A level-order traversal, also known as a breadth-first search, visits each level of a tree's nodes from left to right, top to bottom. You are given a pointer root pointing to the root of a binary search tree. Complete the levelOrder function provided in your editor so that it prints the level-order traversal of the binary search tree.

Hint: You'll find a queue helpful in completing this challenge.

Input Format

  • The locked stub code in your editor reads the following inputs and assembles them into a BST:
  • The first line contains an integer, T (the number of test cases). 
  • The T subsequent lines each contain an integer, data, denoting the value of an element that must be added to the BST.


Output Format

Print the data value of each node in the tree's level-order traversal as a single line of N space-separated integers.

Sample Input

6
3
5
4
7
2
1

Sample Output

3 2 5 1 4 7

Explanation

The input forms the following binary search tree:

Binary search tree example
image Credit:- HackerRank

We traverse each level of the tree from the root downward, and we process the nodes at each level from left to right. The resulting level-order traversal is 3-->2-->5-->1-->4-->7, and we print these data values as a single line of space-separated integers.

Copy the colored code and paste it into Hacker rank editor and click to submit button, but before this process, you have to click the below link, this link takes to you same problem Now you have to just Login if you are already not log in and done. 

Submit this solution:- Click Here

Solution:-

#include <iostream>
#include <cstddef>
#include <queue>
#include <string>
#include <cstdlib>

using namespace std;
class Node{
    public:
        int data;
        Node *left,*right;
        Node(int d){
            data=d;
            left=right=NULL;
        }
};
class Solution{
    public:
  Node* insert(Node* root, int data){
            if(root==NULL){
                return new Node(data);
            }
            else{
                Node* cur;
                if(data<=root->data){
                    cur=insert(root->left,data);
                    root->left=cur;
                }
                else{
                   cur=insert(root->right,data);
                   root->right=cur;
                 }           
           return root;
           }
        }
       
    
  void levelOrder(Node * root){
    queue<Node *> q;
    Node* n = root;
   
    while(n != NULL){
        cout << n->data << ' ';
        
        if( n->left  != NULL ) q.push(n->left);
        if( n->right != NULL ) q.push(n->right);

        if( !q.empty() ) {
        n = q.front();
        q.pop();
        } else {
        n = NULL;
        }
    }
}


};//End of Solution
int main(){
    Solution myTree;
    Node* root=NULL;
    int T,data;
    cin>>T;
    while(T-->0){
        cin>>data;
        root= myTree.insert(root,data);
    }
    myTree.levelOrder(root);
    return 0;
}

Output:-

Binary search Tree Level Order Traversal HackerRank Solution Output


You May Also Check

1. Day 24: More Linked Lists

2. Day 25: Running Time and Complexity

3. Day 26: Nested Logic

4. Day 27: Testing

5. Day 28: RegEx, Patterns, and Intro to Databases
Read More »

3/01/2018

Day 21 Generics HackerRank Solution In C++

Problem:- Day 21 Generics hacker rank solution or HackerRank-30-Days-of-Code/Day 21 Generics or Day 21 Generics/HackerRank-30-Days-of-Code or Day 21 Generics 30 Days of Code solution or Generics HackerRank solution in c or HackerRank Generics solution in c or Generics solution hacker rank or Generics solution hacker rank in c++ or Generics solution in c++ hacker rank or Day 21: Generics | HACKER RANK SOLUTIONS or Hackerrank Day 21: Generics.

Task:- Write a single generic function named printArray; this function must take an array of generic elements as a parameter (the exception to this is C++, which takes a vector). The locked Solution class in your editor tests your function.

Note: You must use generics to solve this challenge. Do not write overloaded functions.

Input Format

The locked Solution class in your editor will pass different types of arrays to your printArray function.

Constraints

You must have exactly 1 function named printArray.

Output Format

Your printArray function should print each element of its generic array parameter on a new line.

Explanation:- We have to just print the generic array, we can do this by using the AUTO keyword in our program. I didn't understand why people don't use AUTO Keyword in C++. as you can see that generic array means all type of data type in an array so for that this is a best practice to use the AUTO keyword in the problem.

Copy the colored code and paste it into Hacker rank editor and click to submit button, but before this process, you have to click the below link, this link takes to you same problem Now you have to just Login if you are already not log in and done. 

Submit this solution:- Click Here

Solution:-

#include <iostream>
#include <vector>
#include <string>

using namespace std;

template <class T> 
    void printArray(vector<T> i) 

    for(int j=0;j<i.size();j++) 
        cout<<i[j]<<endl;



void printArray(vector<auto> a)
{
    for(auto i:a)
        cout<<i<<endl;
}


int main() {
int n;

cin >> n;
vector<int> int_vector(n);
for (int i = 0; i < n; i++) {
int value;
cin >> value;
int_vector[i] = value;
}

cin >> n;
vector<string> string_vector(n);
for (int i = 0; i < n; i++) {
string value;
cin >> value;
string_vector[i] = value;
}

printArray<int>(int_vector);
printArray<string>(string_vector);

return 0;
}

Output:-

Day 21 Generics HackerRank Solution output


You May Also See

1. Day 22: Binary Search Trees

2. Day 23: BST Level-Order Traversal

3. Day 24: More Linked Lists

4. Day 25: Running Time and Complexity

5. Day 26: Nested Logic
Read More »