meteor - How can I access form elements from server function? -
i use mesosphere , want make custom rule validate equalsfield:
mesosphere.registerrule("equalsfield", function(fieldvalue, rulevalue){ //var rulevalue = $('#'+rulevalue).val(); //var rulevalue = document.getelementbyid(rulevalue).value; return fieldvalue === rulevalue; });
but can't use jquery $ or document because not accesible on server side (these works on client side)
so looks want to check 1 field equal field.
in actuality when rule validated in mesosphere, rule passed 5 parameters: fieldvalue, rulevalue, fieldname, formfieldsobject, , fields. since formfieldsobject object containing raw unvalidated data form, name of each input key , current value key value, means can create new rule follows..
mesosphere.registerrule("equalsfield", function(fieldvalue, rulevalue, fieldname, formfieldsobject, fields){ return fieldvalue === formfieldsobject[rulevalue]; });
then when set rules, pass name of field current field should equal , should go.
Comments
Post a Comment