Live Validation change output location

570 Views Asked by At

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

2

There are 2 best solutions below

0
On BEST ANSWER

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.

0
On

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