Last active
August 4, 2018 01:14
-
-
Save gregoryagu/1700f0c7527d729a7edc2377c05de6e5 to your computer and use it in GitHub Desktop.
Materialize Validation - Works
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>GistRun</title> | |
<link rel="stylesheet" href="styles.css"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> | |
<!-- Compiled and minified CSS --> | |
<link rel = "stylesheet" | |
href = "https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/css/materialize.min.css"> | |
<script src = "https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/js/materialize.min.js"></script> | |
</head> | |
<body> | |
<div class="row"> | |
<form id="signUp" class="col s6"> | |
<div class="row"> | |
<div class="input-field col s12"> | |
<input id="company" name="company" type="text" data-length='5' required class="validate" > | |
<label data-error='This is my data error message' data-success='Good Boy' for="company">Team or Company Name *</label> | |
</div> | |
</div> | |
<div class="row"> | |
</div> | |
<div class="row"> | |
<div class="col s12"> | |
<input id="submit" type="submit" value="Go" class="waves-effect waves-light btn"> | |
</div> | |
</div> | |
</form> | |
</div> | |
</div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$( document ).ready(function() { | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$().ready(function () { | |
console.log("init validation"); | |
$("#signUp").validate({ | |
rules: { | |
company: { | |
required: true, | |
minlength: 2 | |
}, | |
agree: { | |
required: true | |
} | |
}, | |
submitHandler: function (form) { // for demo | |
alert('valid form submitted'); // for demo | |
return false; // for demo | |
}, | |
errorClass: 'invalid', | |
errorElement: 'div', | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* todo: add styles */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment