added validation to exercise creation page

This commit is contained in:
2013-01-20 16:35:41 -05:00
parent 536db0e212
commit ce17e701ce
16 changed files with 2006 additions and 90 deletions

View File

@@ -1,25 +1,25 @@
extends ../layout
block additionalscripts
script(src='/javascripts/newexercisevalidation.js')
script(src='/javascripts/newexercisevalidation.js')
block content
h1 New Exercise<p></p>
form(method="POST", action="/admin/exercises")
form(id="newexercise", method="POST", action="/admin/exercises/new")
ul
li
label(for="name") Exercise Name<br />Need to add check to ensure we donbt get duplicate names<br />
label(for="name") Exercise Name<br />
input#name(name="name")
li
label(for="type") Exercise Type<br />
select#type(name="type")
option(value='notselected') Select One
option(value='freeweights') Free Weights
option(value='0130') Exercise Machines
option(value='0200') Bodyweight
option(value='0200') Kettlebells
option(value='0200') Cardio
option(value='machine') Exercise Machines
option(value='bodyweight') Bodyweight
option(value='kettlebells') Kettlebells
option(value='cardio') Cardio
li
label(for="type") Exercise Description<br />
@@ -32,7 +32,7 @@ block content
marray = "musclearray[" + i + "]"
li
label(for="type") Muscle data #{i}
input(name= marray, class= marray, id= marray)
input(name= marray, class="musclearray", id= marray)
- }
li
label(for="type") Keywords<br />

View File

@@ -1,14 +0,0 @@
/script(
$(document).ready(function() {
////Validation
var name = new LiveValidation('name');
name.add( Validate.Format, { pattern: /^\s*[a-zA-Z0-9,\s]+\s*$/ } );
name.add( Validate.Length, { minimum: 3, maximum: 12 , failureMessage: "Please enter a valid name" } );
var type = new LiveValidation('type');
type.add( Validate.Exclusion, { within: ['notselected', 'Select One'], failureMessage: "Please select an entry from the list" } );
var difficulty = new LiveValidation('difficulty');
difficulty.add( Validate.Numericality, { minimum: 1, maximum: 10, onlyInteger: true, failureMessage: "Must be a number between 1 and 10" });
var description = new LiveValidation('description');
description.add( Validate.Format, { pattern: /^\s*[a-zA-Z0-9,\s]+\s*$/ } );
});
/)