webforms - CustomValidator's ClientValidationFunction: is there a way to set trimmed value back to input? -


before validating trim arguments.value. if validation fails, want place trimmed value input. changing arguments.value not have effect. sender (the 1st argument in clientvalidationfunction) validation control message layout, not original input.

i see way: manual search input element id, or name, or class, makes clientvalidationfunction aware input, , have set clientid or unique class input.

validator object passed val parameter of client validation function has controltovalidate field holds unique id of server control (specified in controltovalidate property of customvalidator). can set value control following:

function trimandsetback(val, args) {     // val.controltovalidate hold unique id      // of server control document.getelementbyid work     validatorsetvalue(val.controltovalidate, validatortrim(eventargs.value)); }  function validatorsetvalue(id, value) {     var control;     control = document.getelementbyid(id);      if (typeof (control.value) == "string" && (control.type != "radio" || control.checked == true)) {         control.value = value;         return true;     }      var i;     (i = 0; < control.childnodes.length; i++) {         if (validatorsetvalue(control.childnodes[i], value)) {             return true;         }     }      return false; } 

validatorsetvalue bit modified version of standard validatorgetvaluerecursive function. recursion needed if dealing user controls input control nested inside.


Comments

Popular posts from this blog

javascript - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -