Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dojo - programmatic way to show invalid message

Tags:

dojo

dojo newbie - giving it a shot. After submitting a form, If an error is returned from the server I would like to show that message on the dijit.form.ValidationTextBox

var user_email = dijit.byId("login_user_email");
user_email.set("invalidMessage", data["result"]["user_email"]);
//need to force show the tooltip but how???

Any help much appreciated.

like image 495
Chin Avatar asked Sep 12 '11 05:09

Chin


2 Answers

See it in action at jsFiddle.

  1. Just show tooltip:

    var textBox = bijit.byId("validationTextBox");
    dijit.showTooltip(
        textBox.get("invalidMessage"), 
        textBox.domNode, 
        textBox.get("tooltipPosition"),
        !textBox.isLeftToRight()
    );
    
  2. Temporarily switch textBox validator, force validation, restore the original validator:

    var originalValidator = textBox.validator;
    textBox.validator = function() {return false;}
    textBox.validate();  
    textBox.validator = originalValidator;
    

Or do both at once.

like image 186
phusick Avatar answered Sep 27 '22 22:09

phusick


I think you can show the tooltip via myVTB.displayMessage('this is coming from back end validation'); method

like image 41
arber Avatar answered Sep 27 '22 21:09

arber