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
Just playing around with this CSS Style
span .LV_validation_message {
// properties
}
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;
},
Try this
<div id="lvMsgRegUsername"></div>
...
var reg_username = new LiveValidation('reg_username', { insertAfterWhatNode: "lvMsgRegUsername"});
精彩评论