Skip to content
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
10 changes: 10 additions & 0 deletions coffeevalidator.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
$(".errors li").hide()

$("form").submit(() ->
$(".errors li").hide()
text = $("input[type='text']").val();
pass = $("input[type='password']").val();
$(".errors li:nth-child(1)").show() if !text.match(/.*@.*\..*/)
$(".errors li:nth-child(2)").show() if pass.length<8
$(".errors li:nth-child(3)").show() if !pass.match(/.*[A-Z].*/)
$(".errors li:nth-child(4)").show() if !pass.match(/.*[0-9].*/));
24 changes: 24 additions & 0 deletions coffeevalidator.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ <h1>Sign In</h1>
</ul>
</div>
<script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript"></script>
<script src="validator.js" type="text/javascript"></script>
<script src="coffeevalidator.js" type="text/javascript"></script>
</body>
</html>
12 changes: 12 additions & 0 deletions validator.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
$(".errors li").hide()

$("form").submit(validate);

validate = () ->
$(".errors li").hide()
text = $("input[type='text']").val();
pass = $("input[type='password']").val();
$(".errors li:nth-child(1)").show() if !text.match(/.*@.*\..*/)
$(".errors li:nth-child(2)").show() if pass.length<8
$(".errors li:nth-child(3)").show() if !pass.match(/.*[A-Z].*/)
$(".errors li:nth-child(4)").show() if !pass.match(/.*[0-9].*/)
19 changes: 14 additions & 5 deletions validator.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
$(".errors li").hide()

//insert your code here

$(function(){

//insert your code here
$("form").submit(function(){
$(".errors li").hide()
var text = $("input[type='text']").val();
var pass = $("input[type='password']").val();
if (!text.match(/.*@.*\..*/)){
$(".errors li:nth-child(1)").show()
}if(pass.length<8){
$(".errors li:nth-child(2)").show()
}if(!pass.match(/.*[A-Z].*/)){
$(".errors li:nth-child(3)").show()
}if(!pass.match(/.*[0-9].*/)){
$(".errors li:nth-child(4)").show()
}
});