2

I'm using the Live Validation Javascript library and I'm wondering how I can use it to place the feedback at the bottom of the page.

For instance, a user would input "asdf.com" in <input type="text" id="subdomain-name" name="subdomain-name">

And I would want Live-Validation to respond back "A sub-domain should not include periods." but at the bottom of the page, because otherwise it would mess up the text that is located after the box: http://puu.sh/3IxDc.jpg.

I tried to create a CSS div and then reference that as span in

createMessageSpan: function(){
    var span = document.createElement('span');
    var textNode = document.createTextNode(this.message);
    span.appendChild(textNode);
    return span;
},

but that did not work

Antony
  • 14,900
  • 10
  • 46
  • 74
Matthew Salsamendi
  • 294
  • 1
  • 5
  • 14

2 Answers2

0

You can use jquery and the html() function. I know this isn't Live Validation but this will work.

The HTML

<html>
<head>
<script src="jquery.js"></script>
</head>
<body>
All your other html here
<div id="suggestion"></div>
</body>
</html>

The javascript

if(THE CODE THAT DETERMINES IF MESSAGE IS NECESSARY){
    $("#suggestion").html("A sub-domain should not include periods."); 
}

JsFiddle

Noah Huppert
  • 4,028
  • 6
  • 36
  • 58
0

By using the

insertAfterWhatNode

Property I was able to do it, example:

var port = new LiveValidation("subdomain-port", {validMessage: "Port is valid", insertAfterWhatNode: "error"});

Where "error" is the element id of where you want it after.

Matthew Salsamendi
  • 294
  • 1
  • 5
  • 14