Execute
Save
Share
Share link
share
share
share
Team
Public Teams
Comments
0
Created By:
Guest
Title:
Title
Description
Edit
Copy Link
Login
Email *
Password *
Login
OR
Create Account
Screen Name *
Email *
Password *
Retype Password *
Team Access Code
Register
Public CodeBins
HELP
--Select Theme--
Ambiance
Blackboard
Cobalt
Eclipse
Elegant
Erlang-Dark
Lesser-Dark
Monokai
Neat
Night
Rubyblue
Vibrant-Ink
Xq-Dark
New CodeBin
CodeBins Versions
02/24/2017- V.3
02/24/2017- V.2
02/24/2017- V.1
Compare Versions
Recent CodeBins
View All CodeBins
function validate() { var studentid = document.getElementById("studentid").value; var name = document.getElementById("name").value; var email = document.getElementById("email").value; if (nameEmpty(name)) { if (studentidEmpty(studentid)) { if (emailEmpty(email)) { if (digitCheck(studentid)) { if checkEmail(email) { verify(name, studentid) } } } } } return false; } function studentidEmpty(studentid) { if (studentid == "") { alert("Please provide your student id!"); studentid.focus(); return false; } } function nameEmpty(name) { if (name == "") { alert("Please provide your name!"); name.focus(); return false; } } function emailEmpty(email) { if (email == "") { alert("Please provide your email!"); email.focus(); return false; } function digitCheck(studentid) { var ok = studentid.search(".{8,}"); if (ok != 0) { alert("Please provide ID with 8 digits."); return false; } } function checkEmail(email) { var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (!filter.test(email.value)) { alert('Please provide a valid email address'); email.focus; return false; } } function verify(name, studentid) { var personList = [ ["Joe", 11111111], ["Tammy", 22222222], ["Jones", 33333333] ]; for (list in personList) { if (name in list && studentid in list) { alert("Welcome! An email verification with be sent soon."); return true; } else { alert("Student Name and/or ID not found in records"); return false; } } } }
Bottom of Page
In Head
On Load
On Ready
Setting
Validate
Copy
Format
body{ background: lightblue; line-height: 2em } input[type=text] { border: 2px solid black; border-radius: 4px; } input[type=number] { border: 2px solid black; border-radius: 4px; } .container { width: 500px; clear: both; } .container input { width: 100%; clear: both; }
Setting
Validate
Copy
Format
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Student Login Form</title> <link rel='stylesheet' href='studentform.css' type='text/css' /> <script src="studentform.js"></script> </head> <body onload="document.form.studentid.focus();"> <h1>Student Login</h1> <div class="container"> <form name="form" onsubmit="return validate();"> <label for="studentid">Student ID:</label> <input type="number" name="studentid" maxlength="8" id="studentid" required /> <label for="name">Name:</label> <input type="text" name="name" size="50" id="name" required /> <label for="email">Email:</label> <input type="email" name="email" size="50" id="email" required /> <label for="emailconfirm">Email Confirmation:</label> <input type="checkbox" name="emailconfirm" checked /><span>Send an email confirmation</span> <select> <option selected>Student Registration</option> <option>Transcript</option> </select> <input type="submit" name="submit" value="Submit" /> </form> </div> </body> </html>
No Doc Type
HTML5
HTML 4.01 Transitional
HTML 4.01 Strict
HTML 4.01 Frameset
XHTML 1.1
XHTML 1.0 Transitional
XHTML 1.0 Strict
XHTML 1.0 Frameset
Copy
Format
Download
×
Code Description
×
Difference of Versions
HTML
CSS
JS
×
JS Error
×
CSS Error
Errors
Warnings
×
JavaScript Setting
JS Libraries:
Chrome Frame 1.0.3
Dojo 1.8.0
Dojo 1.7.3
Dojo 1.7.2
Ext Core 3.1.0
jQuery 1.8.0
jQuery 1.7.2
jQuery 1.6.0
jQuery 1.5.0
jQuery 1.4.4
jQuery 1.4.0
jQuery-min 1.7.2
jQueryUI-min 1.8.21
MooTools more-1.4.0.1-full
MooTools core-1.4.5-full
MooTools core-1.4.1-full
Prototype 1.7.1.0
script.aculo.us 1.9.0
SWFObject 2.2
Twitter Bootstrap 2.0.4
WebFont Loader 1.0.28
yui 3.5.1
User Libraries:
Upload File
JavaScript URL(s):
×
CSS Setting
CSS Libraries:
jQueryUI 1.8.21
Twitter Bootstrap 2.0.4
User Libraries:
Upload File
CSS URL(s):