JK.
JK.

Reputation: 21829

Livevalidation clientside validation - can you control the position of the validation messages?

I'm using LiveValidaion for my clientside validation http://livevalidation.com/ and DataAnnotations for my validation rules. This all works fine except that the clientside error messages are only ever displayed to the right of the element being validated.

Is it possible to move this validation message below the element being validated? Or even better, group all messages in a div at the top/bottom of the page? I dont see anything in their docs or examples

Upvotes: 0

Views: 991

Answers (3)

gX.
gX.

Reputation: 962

Try this

<div id="lvMsgRegUsername"></div>
...
var reg_username = new LiveValidation('reg_username', { insertAfterWhatNode: "lvMsgRegUsername"});

Upvotes: 0

ussteele
ussteele

Reputation: 133

This is what I did.

first is the original code from LiveValidation 1.3 - standalone version, in firebug on firefox it is at line 353.

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

here is what I changed code to.

createMessageDiv: function(){
    var divMessage = document.createElement('div'); 
    divMessage.id = "lvID";
    divMessage.style.position = "absolute";  
    divMessage.setAttribute("align","left");
    divMessage.style.marginLeft = "2px"; 
    var textNode = document.createTextNode(this.message);
    divMessage.appendChild(textNode);
    return divMessage;
}, 

Upvotes: 0

Just playing around with this CSS Style

span .LV_validation_message {
    // properties
}

Upvotes: 1

Related Questions