Reputation: 1057
I downloaded LiveValidation to see if it would work for my site and for some reason my test code isn't working. Could anyone give a hand?
<html>
<head>
<title>Test</title>
<script type="text/javascript" src="livevalidation.js"></script>
</head>
<body>
<form name="example_form" action="#" method="POST">
<input style="width:50px;" name="name" type="text" />
<script>
var f1 = new LiveValidation('name');
f1.add(Validate.Presence);
</script>
<button class="button gray" type="submit" name="submit">Submit</button>
</form>
</body>
</html>
Upvotes: 0
Views: 721
Reputation: 1
For adding an element to LiveValidation object id must be declared in field. This will do your code running.
<input style="width:50px;" name="name" id="someIdName" type="text" />
then add it object by Id name which u had specified :
<script>
var f1 = new LiveValidation('someIdName');
f1.add(Validate.Presence);
</script>
Upvotes: 0
Reputation: 4965
First the field is set up to be a LiveValidation object, by passing in its id as the first argument.
You have passed in 'name' which is the value of name. You need an id.
i.e.
<input id="name" style="width:50px;" name="name" type="text" />
Upvotes: 1