"Registration Form and Validation"
Bootstrap 3.3.0 Snippet by tradesouthwest

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<div class="row">
<div class="col-md-6">
<form action="" method="post" id="fileForm" role="form">
<fieldset><legend class="text-center">Valid information is required to register. <span class="req"><small> required *</small></span></legend>
<div class="form-group">
<label for="phonenumber"><span class="req">* </span> Phone Number: </label>
<input required type="text" name="phonenumber" id="phone" class="form-control phone" maxlength="28" onkeyup="validatephone(this);" placeholder="not used for marketing"/>
</div>
<div class="form-group">
<label for="firstname"><span class="req">* </span> First name: </label>
<input class="form-control" type="text" name="firstname" id = "txt" onkeyup = "Validate(this)" required />
<div id="errFirst"></div>
</div>
<div class="form-group">
<label for="lastname"><span class="req">* </span> Last name: </label>
<input class="form-control" type="text" name="lastname" id = "txt" onkeyup = "Validate(this)" placeholder="hyphen or single quote OK" required />
<div id="errLast"></div>
</div>
<div class="form-group">
<label for="email"><span class="req">* </span> Email Address: </label>
<input class="form-control" required type="text" name="email" id = "email" onchange="email_validate(this.value);" />
<div class="status" id="status"></div>
</div>
<div class="form-group">
<label for="username"><span class="req">* </span> User name: <small>This will be your login user name</small> </label>
<input class="form-control" type="text" name="username" id = "txt" onkeyup = "Validate(this)" placeholder="minimum 6 letters" required />
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
body {
padding-top:50px;
}
fieldset {
border: thin solid #ccc;
border-radius: 4px;
padding: 20px;
padding-left: 40px;
background: #fbfbfb;
}
legend {
color: #678;
}
.form-control {
width: 95%;
}
label small {
color: #678 !important;
}
span.req {
color:maroon;
font-size: 112%;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function checkPass()
{
//Store the password field objects into variables ...
var pass1 = document.getElementById('pass1');
var pass2 = document.getElementById('pass2');
//Store the Confimation Message Object ...
var message = document.getElementById('confirmMessage');
//Set the colors we will be using ...
var goodColor = "#66cc66";
var badColor = "#ff6666";
//Compare the values in the password field
//and the confirmation field
if(pass1.value == pass2.value){
//The passwords match.
//Set the color to the good color and inform
//the user that they have entered the correct password
pass2.style.backgroundColor = goodColor;
message.style.color = goodColor;
message.innerHTML = "Passwords Match"
}else{
//The passwords do not match.
//Set the color to the bad color and
//notify the user.
pass2.style.backgroundColor = badColor;
message.style.color = badColor;
message.innerHTML = "Passwords Do Not Match!"
}
}
function validatephone(phone)
{
var maintainplus = '';
var numval = phone.value
if ( numval.charAt(0)=='+' )
{
var maintainplus = '';
}
curphonevar = numval.replace(/[\\A-Za-z!"£$%^&\,*+_={};:'@#~,.Š\/<>?|`¬\]\[]/g,'');
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: