View Full Version : Ext.message box
captainm1uk
09-26-2007, 09:31 AM
Hi
I have a form and in it I am using the forms.js for a simple layout. I am using validation fields on this form and when the user presses submit, i want to put a message box in the onSubmit
Basically I want it to say if validation has passed on form then ext.messagebox...... else ext.messagebox...- please fill in fields
Thanks
RWaters
09-26-2007, 08:32 PM
Are you trying to just use the built-in Domino field validation with @formulas? or Ext VTypes or did you write some custom Javascript validation?
Currently I don't know that there's a good way to get at the built-in field validation with javascript, unless we can come up with some wacky form DXL exporting that can manage to convert common @formulas into javascript validation.... (I wouldn't hold your breath on that one)
If you're looking for a messagebox I would think a small custom javascript routine to validate would be the quickest/easiest solution. You could even call the Ext fields markInvalid and clearInvalid methods...
I know validation is really a big deal and is commonly needed, I'll see what else we can come up with. Perhaps some additional class names you could add that convert a field and add a VType to it...
captainm1uk
09-27-2007, 06:04 AM
Hi
Thanks for this - I am using the allowBlank:false in the simple forms box but what I also want is if they leave it blank and press submit then they get the prompt - also if they press close they get a message saying "are you sure?". I am not too good at present at the js code so an example would be nice
Thanks
ps - I like the ext.nd demo db from your site :)
bhaidaya
09-27-2007, 10:11 AM
A very simple version of this that i have is:
a validation function something like this
function ValidateFields() {
return extForm.isValid();
}
and a document submit function:
This IS NOT ext.nd compatible but should set you in the right direction. This was written before alpha 2 and also checks our integrated tinyMCE editor so ignore those...
function submitDoc() {
var iframeDoc = getIframeDocument('center-iframe');
var targetWindow = Ext.get('center-iframe').dom.contentWindow;
if ( targetWindow.doValidateFields == true ) {
if ( targetWindow.ValidateFields() == false ) {
Ext.Msg.alert( 'Submit', 'Enter required values in highlighted fields before submitting' );
return false;
}
}
if ( targetWindow.doMCEOnSubmit == true ) {
tinyMCE.triggerSave();
targetWindow.doMCEOnSubmit = null;
}
iframeDoc.forms[0].submit();
if ( targetWindow.PostCloseAction ) {
switch( targetWindow.PostCloseAction ) {
case 'close' : updatePanel( 'Focus', 'center', 'center-content-panel' ); break;
case 'close+refresh' : updatePanel( 'Refresh', 'center', 'center-content-panel' ); break;
}
}
// cleanup
iframeDoc, targetWindow = null;
}
captainm1uk
09-27-2007, 10:56 AM
Hi - sorry to be a pain but i am very new to this so part one - were would that go and part 2 where would that go, and how does it know what fields to validate
Thanks
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.