Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jquery #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title></title>
</head>
<body>
<form action="" method="get">
Email: <input id="email" type="text">
<button type="submit">
<marquee behavior="" direction="">Click me!</marquee>
</button>
</form>
</body>
<script
src="https://code.jquery.com/jquery-3.3.1.js"
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
crossorigin="anonymous">
</script>
<script src="./lib/validate-email.js"></script>
</html>
19 changes: 19 additions & 0 deletions lib/validate-email.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$('#email').keyup(function (){
let email = this.value
validateEmail(email)
})
let count = 0
function validateEmail(email){
let regex = new RegExp(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/)
if(!regex.test(email)){
$('#email').css('border','4px solid red')
if(count === 0){
$('form').append(`<span id="error_message" style="color:red">Email address is not valid</span>`)
}
count++
} else {
$('#email').css('border','4px solid green')
$('#error_message').remove()
count=0
}
}
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "jquery-plugin",
"version": "1.0.0",
"description": "your own jquery plugin",
"main": "index.js",
"directories": {
"lib": "lib"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/fzgitara/jquery-plugin.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/fzgitara/jquery-plugin/issues"
},
"homepage": "https://github.com/fzgitara/jquery-plugin#readme"
}