javascript - How do I highlight all invalid dijit.form.ValidationTextBoxes on a dijit.form.Form? -


The one I am after is a form that is submitted, runs a verification check, and all invalid fields Highlights and adds tooltips.

I'm looking for something like this effectively:

  dojo.forEach (dijit.byId ('myForm'). Invalid wickets, function ( ThisWidget, index, array) {ThisWidget.displayMessage ("General invalid / empty message should go here, I think some high level calls from this");});  

But I do not want to dig that deep, what I want to do is the trigger of the same trigger that triggers when you get out of the empty area (exclamation point and Proper invalid / empty message) Maybe I should try a tab-out event?

Can anyone tell me in the right direction?

Yes, you are right - you can achieve all your beliefs, highlight , By focusing on the previously invalid field validate () function on the Dijit.form.form.phorm element.

Here's an example where valid () call is added to the onsite event:

  & lt; Head & gt; & Lt; Script type = "text / javascript" & gt; Dojo.require ("dojo.parser"); Dojo.require ("dojo.form.Form"); Dojo.require ("dojo.form.ValidationTextBox"); Dojo.require ("dojo.form.Button"); // More here ... & lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form dojoType = "dijit.form.form" verb = "..." method = "..." & gt; & Lt; Input dojoType = "dijit.form.ValidationTextBox" trim = "true" regExp = "..." Invalid message = "Oh ..." & gt; & Lt ;! - // More form elemts here ... - & gt; & Lt; Button type = "submit" dojoType = "dijit.form.Button" ... & gt; & Lt; / Button & gt; Submit & lt; Script type = "dojo / method" event = "onsite" & gt; If (! This.validate ()) {Warning ("The form contains invalid data, please correct ...."); return false; } Back true; & Lt; Script & gt; & Lt; / Form & gt; & Lt; / Body & gt;  

Hope you find it useful.

Cheers.


Follow-up: Here is an example of an input field to help indicate the type of data the user expects. Can be used, and alert them when verification fails:

  & lt; Input type = "text" id = "EXT" name = "EXT" value = "" maxLength = "10" dojoType = "dijit.form.ValidationTextBox" regExp = "\ d +?" Trim = "true" prompt message = "& lt; p class = 'help' & gt; please enter your extension. (I.e." 1234 ") & lt; / p & gt; Invalid message = "& lt; p class = 'help' & gt; extension field should contain only numbers. & Lt; / p & gt;" & Gt;  

This is an declarative example (I mis-spelled it in my initial reaction.)


Comments