Re: [flexcoders] Re: BETA 2: How to validate a form before actually submitting

2006-04-04 Thread Oriol Gual



Hi Alex,Sorry, I hardcoded it while writing the email and I made some mistakes:1. Add this import:import mx.controls.Alert;2 . Change vars decalaration toprivate var stringvalidation : String;

private var stringvalidation2 : String;I think it's all correct now.See you, Oriol.2006/4/4, Alex  Alex [EMAIL PROTECTED]
:Hi Oriol,This *sounds* a lot better though I am getting these errors at
compile time.1::Implicit coercion of a value of type 'String' to an unrelatedtype 'mx.events:ValidationResultEvent (this error appears twice)2::Comparison between a value with statictype 'mx.validators:StringValidator
' and a possibly unrelatedtype 'String' (this error appears twice)3::Access of undefined property 'alert'I'm not such of an actionscript guy, but I'll get there sooner orlater. Thanks again.
Alex--- In flexcoders@yahoogroups.com, Oriol Gual [EMAIL PROTECTED]wrote: Hi Alexander, Thanks to your observation I've came to a better solution:
 mx:Script ![CDATA[ import mx.events.ValidationResultEvent; private function checkValidators() : Boolean { stringvalidation= stringvalidator.validate
().type; stringvalidation2 = stringvalidator2.validate().type; if ( (stringvalidator == ValidationResultEvent.VALID) (stringvalidator2 == ValidationResultEvent.VALID) ) { return true;
 } else { return false; } } private function sendForm() : void { if(checkValidators()) { //do whatever you have to do to send the form } else {
 alert.show(Form is not valid!,Alert); } } private var stringvalidation : ValidationResultEvent; private var stringvalidation2 : ValidationResultEvent; ]]
 /mx:Script mx:StringValidator id=stringvalidator source={inputText} property=text minLength=3 maxLength=20trigger={inputText} triggerEvent=change/
 mx:StringValidator id=stringvalidator2 source={inputText} property=text minLength=3 maxLength=20trigger={inputText2} triggerEvent=change/
 mx:Form mx:FormItem label=Input some text required=truedirection=horizontal fontWeight=bold textAlign=left
 mx:TextInput id=inputText width=80 maxChars=20//mx:FormItem mx:FormItem label=Input some other text required=true direction=horizontal fontWeight=bold textAlign=left
 mx:TextInput id=inputText2 width=80 maxChars=20//mx:FormItem /mx:Form mx:Button id=fromButton label=Send form click=sendForm()/
 Some explanation and changes: - Removed the valid/invalid properties of the validators. - Added an id for each one. - Instead of doing this: if ( (stringvalidator.validate
 ().type== ValidationResultEvent.VALID)  (stringvalidator2.validate().type== ValidationResultEvent.VALID) ) which is also correct, I think it'sbetter to do it with the variables, and then evaluating them, because you
validate all the fields (and the tooltip errors are shown, like you wantedAlexander), the other way if the first fails the other fields won't bevalidated. Hope this helps,
 Oriol 2006/4/3, Alexander Tsoukias [EMAIL PROTECTED]:  While this does the trick, what if I have 3 inputs? While onepasses the  validation the sendForm() will be executed while the other 2
inputs are  still unvalidated? I want to make sure all of them are validatedbefore  executing sendForm().   BTW, cool about the on change validation. One thing though... is
there a  way to make the error tooltip show up programatically instead ofhaving to  hover over my mouse pointer?   Thanks,  Alexander   *Oriol Gual  
[EMAIL PROTECTED]* wrote:   Hi,   What I do to validate a form, is somethig like this:   mx:Script  ![CDATA[ 
  private function handleValid(eventObj:ValidationResultEvent) :void  {  if(eventObj.type==ValidationResultEvent.VALID ) {  formValid = true;
  } else {  formValid = false;  }  }  private function sendForm() : void  {  if(formValid) {
  //do whatever you have to do to send the form  } else {  alert.show(Form is not valid!,Alert);  }  }   private var formValid : Boolean = false;
   ]]  /mx:Script   mx:StringValidator source={inputText} property=textminLength=3  maxLength=20
 trigger={inputText} triggerEvent=change valid=handleValid(event)  invalid=handleValid(event)/   mx:Form
  mx:FormItem label=Input some text required=true  direction=horizontal fontWeight=bold textAlign=left  mx:TextInput id=inputText width=80 maxChars=20/
 /mx:FormItem  /mx:Form  mx:Button id=fromButton label=Send form click=sendForm()/   When the user inputs some text in the textinput the validation
occurs  automatically ( trigger={inputText} triggerEvent=change) andthe  function handleValid is called. Then, when clicking the buttonif the  variable formValid it's true we can send the form.
   By the way, I have a question, what is the meaning of the modelswith flex  2 and forms? Because they're declared in the examples but thevalidators  don't use them.
   Hope this helps,   Oriol2006/4/2, Dreamer  [EMAIL PROTECTED]:Alex  Alex,  
  you can put the data be validated in amodel.like this:   mx:Model id=order   email{ 
email.text }/email//email is   a textInput controller's id   /mx:Model   then define a validator:mx:EmailValidator 

RE: [flexcoders] Re: BETA 2: How to validate a form before actually submitting

2006-04-04 Thread Jason Hawryluk





You could start by 
reading the help.

Developing Flex 
Applications - Validating Data

Then after that come 
back and ask a question, if you’re stuck.

This 
is not meant to be harsh; it's better for you to learn by trial and error. 
Figuring out these types of problems or questions will lead to your having a 
deep understanding of Flex and the framework.
Jason

-Message 
d'origine-De: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED]De la part de Alexander 
TsoukiasEnvoyé: mardi 4 avril 2006 14:56À: 
flexcoders@yahoogroups.comObjet: Re: [flexcoders] Re: BETA 2: 
How to validate a form before actually submitting

  Ok cool it all worked fine!! And now to take it up a noch
  
  How can I do the following 2 things:
  
  1) Display the red error tooltip while typing
  2) How can I have the submit button disabled and when all the validation 
  is through to enable it for submittion.
  
  Thanks,
  Alexander
  
  Oriol Gual [EMAIL PROTECTED] 
wrote:
  Hi 
Alex,Sorry, I hardcoded it while writing the email and I made some 
mistakes:1. Add this import:import 
mx.controls.Alert;2 . Change vars decalaration toprivate var 
stringvalidation : String; private var stringvalidation2 : 
String;I think it's all correct now.See you, 
Oriol.
2006/4/4, Alex  Alex [EMAIL PROTECTED] : 
Hi 
  Oriol,This *sounds* a lot better though I am getting these errors 
  at compile time.1::Implicit coercion of a value of type 
  'String' to an unrelatedtype 'mx.events:ValidationResultEvent (this 
  error appears twice)2::Comparison between a value with 
  statictype 'mx.validators:StringValidator ' and a possibly 
  unrelatedtype 'String' (this error appears twice)3::Access of 
  undefined property 'alert'I'm not such of an actionscript guy, but 
  I'll get there sooner orlater. Thanks again.Alex--- In 
  flexcoders@yahoogroups.com, 
  "Oriol Gual" [EMAIL PROTECTED]wrote: Hi 
  Alexander, Thanks to your observation I've came to a 
  better solution:  
  mx:Script ![CDATA[ 
  import mx.events.ValidationResultEvent; private function 
  checkValidators() : Boolean { 
  stringvalidation= stringvalidator.validate ().type; 
  stringvalidation2 = stringvalidator2.validate().type; if ( 
  (stringvalidator == ValidationResultEvent.VALID) 
  (stringvalidator2 == ValidationResultEvent.VALID) ) 
  { return true;  } else { return false; 
  } } private function sendForm() : void 
  { if(checkValidators()) { //do whatever you have to do to 
  send the form } else {  alert.show("Form is not 
  valid!","Alert"); } } private var stringvalidation 
  : ValidationResultEvent; private var stringvalidation2 : 
  ValidationResultEvent; ]]  
  /mx:Script mx:StringValidator 
  id="stringvalidator" source="{inputText}" property="text" 
  minLength="3" maxLength="20"trigger="{inputText}" 
  triggerEvent="change"/  mx:StringValidator 
  id="stringvalidator2" source="{inputText}" property="text" 
  minLength="3" maxLength="20"trigger="{inputText2}" 
  triggerEvent="change"/  mx:Form 
  mx:FormItem label="Input some text" 
  required="true"direction="horizontal" fontWeight="bold" 
  textAlign="left" mx:TextInput id="inputText" width="80" 
  maxChars="20"//mx:FormItem 
  mx:FormItem label="Input some other text" required="true" 
  direction="horizontal" fontWeight="bold" textAlign="left"  
  mx:TextInput id="inputText2" width="80" 
  maxChars="20"//mx:FormItem 
  /mx:Form mx:Button id="fromButton" label="Send form" 
  click="sendForm()"/  Some explanation and 
  changes: - Removed the valid/invalid properties of the 
  validators. - Added an id for each one. - Instead of doing 
  this: if ( (stringvalidator.validate ().type== 
  ValidationResultEvent.VALID)  
  (stringvalidator2.validate().type== ValidationResultEvent.VALID) ) 
  which is also correct, I think it'sbetter to do it with the 
  variables, and then evaluating them, because you validate all 
  the fields (and the tooltip errors are shown, like you 
  wantedAlexander), the other way if the first fails the other 
  fields won't bevalidated. Hope this helps, 
   Oriol 2006/4/3, Alexander Tsoukias 
  [EMAIL PROTECTED]:  While this 
  does the trick, what if I have 3 inputs? While onepasses the 
   validation the sendForm() will be executed while the other 2 
  inputs are  still unvalidated? I want to make sure all of 
  them are validatedbefore  executi

Re: [flexcoders] Re: BETA 2: How to validate a form before actually submitting

2006-04-03 Thread Oriol Gual



Hi, What I do to validate a form, is somethig like this:mx:Script ![CDATA[ private function handleValid(eventObj:ValidationResultEvent) : void  {   if(eventObj.type==ValidationResultEvent.VALID
) {formValid = true;   } else {formValid = false;   }   } private function sendForm() : void{
if(formValid) {//do whatever you have to do to send the form} else {alert.show(Form is not valid!,Alert);}}private var formValid : Boolean = false;]]
/mx:Scriptmx:StringValidator source={inputText} property=text minLength=3 maxLength=20 trigger={inputText} triggerEvent=change valid=handleValid(event) invalid=handleValid(event)/
mx:Formmx:FormItem label=Input some text required=true direction=horizontal fontWeight=bold textAlign=left
mx:TextInput id=inputText width=80 maxChars=20//mx:FormItem/mx:Formmx:Button id=fromButton label=Send form click=sendForm()/
When the user inputs some text in the textinput the validation occurs automatically ( trigger={inputText} triggerEvent=change) and the function handleValid is called. Then, when clicking the button if the variable formValid it's true we can send the form.
By the way, I have a question, what is the meaning of the models with flex 2 and forms? Because they're declared in the examples but the validators don't use them.Hope this helps,Oriol
2006/4/2, Dreamer [EMAIL PROTECTED]:
Alex  Alex, you can put the data be validated in a model.like this:mx:Model id=orderemail{email.text
}/email//email is a textInput controller's id/mx:Modelthen define a validator: mx:EmailValidator field=order.email/then write a function in the script tag:
function confirmOrder(): Void {if (mx.validators.Validator.isStructureValid(this, 'order')) {mx.controls.Alert.show(Success!!);addMember();
}else {mx.controls.Alert.show(Please enter valid data in the fields with errors and try again., Problem);}} Peace,Dreamerin china
[EMAIL PROTECTED]2006-04-02=== 2006-04-02 01:37:17 :===Hi Mike,I understand the login, but how do I reference the validation?
I mean what would actually go where you have validation is success.I'm not an actionscrip expert! I'm a cfforever guy ;-).Alexander--- In 
flexcoders@yahoogroups.com, Dreamer [EMAIL PROTECTED] wrote: Alex  Alex,you can write a function,like that.if(validation is success)
addMember();elsealert(invalid input!!!);Peace, Dreamer [EMAIL PROTECTED]
 2006-04-01 === 2006-04-01 18:32:22 :===  Hello,  In a signup form, when I click the submit button I would like for
all the validation to happen and then actually hit the addMember() function.  But if a form fails the validation how can I prevent theexecution of
 addMember().  Thanks, Alexander  -- Flexcoders Mailing List
 FAQ:http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: 
http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links 
   = = = = = = = = = = = = = = = = = = = =--Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txtSearch Archives: 
http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links= = = = = = = = = = = = = = = = = = = =--Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txtSearch Archives: 
http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links* To visit your group on the web, go to:http://groups.yahoo.com/group/flexcoders/
* To unsubscribe from this group, send an email to:[EMAIL PROTECTED]* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





  




  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  









Re: [flexcoders] Re: BETA 2: How to validate a form before actually submitting

2006-04-03 Thread Alexander Tsoukias



While this does the trick, what if I have 3 inputs? While one passes the validation the sendForm() will be executed while the other 2 inputs are still unvalidated? I want to make sure all of them are validated before executing sendForm().BTW, cool about the on change validation. One thing though... is there a way to make the error tooltip show up programatically instead of having to hover over my mouse pointer?Thanks,  AlexanderOriol Gual [EMAIL PROTECTED] wrote:  Hi, What I do to validate a form, is somethig like this:mx:Script ![CDATA[ private function handleValid(eventObj:ValidationResultEvent) : void  {
   if(eventObj.type==ValidationResultEvent.VALID ) {formValid = true;   } else {formValid = false;   }   } private function sendForm() : void{  if(formValid) {//do whatever you have to do to send the form} else {alert.show("Form is not valid!","Alert");}}private var formValid : Boolean = false;]]/mx:Scriptmx:StringValidator source="{inputText}" property="text" minLength="3" maxLength="20" trigger="{inputText}" triggerEvent="change"
 valid="handleValid(event)" invalid="handleValid(event)"/ mx:Formmx:FormItem label="Input some text" required="true" direction="horizontal" fontWeight="bold" textAlign="left"  mx:TextInput id="inputText" width="80" maxChars="20"//mx:FormItem/mx:Formmx:Button id="fromButton" label="Send form" click="sendForm()"/ When the user inputs some text in the textinput the validation occurs automatically ( trigger="{inputText}" triggerEvent="change") and the function handleValid is called. Then, when clicking the button if the variable formValid it's true we can send the form. By the way, I have a question, what is the meaning of the models with flex 2 and forms? Because they're declared in the examples but the validators don't use them.Hope this helps,Oriol  2006/4/2, Dreamer [EMAIL PROTECTED]:  Alex  Alex, you can put the data be validated in a model.like this:mx:Model id="order"email{email.text }/email//email is a textInput controller's
 id/mx:Modelthen define a validator: mx:EmailValidator field="order.email"/then write a function in the script tag: function confirmOrder(): Void {if (mx.validators.Validator.isStructureValid(this, 'order')) {mx.controls.Alert.show("Success!!");addMember();}else
 {mx.controls.Alert.show("Please enter valid data in the fields with errors and try again.", "Problem");}}Peace,Dreamerin china [EMAIL PROTECTED]2006-04-02=== 2006-04-02 01:37:17 £º===Hi Mike,I understand the login, but how do I reference the validation?I mean what would actually go where you have "validation is success".I'm not an actionscrip expert! I'm a cfforever guy ;-).Alexander--- In flexcoders@yahoogroups.com, "Dreamer" [EMAIL PROTECTED] wrote: Alex 
 Alex,you can write a function,like that.if(validation is success) addMember();elsealert("invalid input!!!");Peace, Dreamer [EMAIL PROTECTED]  2006-04-01 === 2006-04-01 18:32:22 £º===  Hello,  In a signup form, when I click the submit button I would like for all the validation to happen and then actually hit the addMember() function.  But if a form
 fails the validation how can I prevent theexecution of  addMember().  Thanks, Alexander  -- Flexcoders Mailing List  FAQ:http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links = = = = = = = = = = = = = = = = = = =
 =--Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txtSearch Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links= = = = = = = = = = = = = = = = = = = =--Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txtSearch Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links* To visit your group on the web, go
 to:http://groups.yahoo.com/group/flexcoders/ * To unsubscribe from this group, send an email to:[EMAIL PROTECTED]* Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/  YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web.   To unsubscribe from this group, send an email to:[EMAIL PROTECTED]   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.   





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





  




  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  









Re: [flexcoders] Re: BETA 2: How to validate a form before actually submitting

2006-04-03 Thread Oriol Gual



Hi Alexander,Thanks to your observation I've came to a better solution:mx:Script ![CDATA[ import mx.events.ValidationResultEvent;private function checkValidators() : Boolean
{stringvalidation = stringvalidator.validate().type;stringvalidation2 = stringvalidator2.validate().type;if ( (stringvalidator == ValidationResultEvent.VALID)  (stringvalidator2 == 
ValidationResultEvent.VALID) ) {return true;} else {return false;}}private function sendForm() : void{


if(checkValidators()) {//do whatever you have to do to send the form} else {alert.show(Form is not valid!,Alert);}}private var stringvalidation : ValidationResultEvent;
private var stringvalidation2 : ValidationResultEvent;]]
/mx:Scriptmx:StringValidator id=stringvalidator source={inputText} property=text minLength=3 maxLength=20 trigger={inputText} triggerEvent=change/
mx:StringValidator id=stringvalidator2 source={inputText} property=text minLength=3 maxLength=20 trigger={inputText2} triggerEvent=change/
mx:Formmx:FormItem label=Input some text required=true direction=horizontal fontWeight=bold textAlign=left


mx:TextInput id=inputText width=80 maxChars=20//mx:FormItemmx:FormItem label=Input some other text required=true direction=horizontal fontWeight=bold textAlign=left

mx:TextInput id=inputText2 width=80 maxChars=20//mx:FormItem/mx:Formmx:Button id=fromButton label=Send form click=sendForm()/
Some explanation and changes:- Removed the valid/invalid properties of the validators.- Added an id for each one.- Instead of doing this: if ( (stringvalidator.validate

().type== ValidationResultEvent.VALID)  (stringvalidator2.validate().type== ValidationResultEvent.VALID) ) which is also correct, I think it's better to do it with the variables, and then evaluating them, because you validate all the fields (and the tooltip errors are shown, like you wanted Alexander), the other way if the first fails the other fields won't be validated.
Hope this helps,Oriol2006/4/3, Alexander Tsoukias [EMAIL PROTECTED]
:



While this does the trick, what if I have 3 inputs? While one passes the validation the sendForm() will be executed while the other 2 inputs are still unvalidated? I want to make sure all of them are validated before executing sendForm().
BTW, cool about the on change validation. One thing though... is there a way to make the error tooltip show up programatically instead of having to hover over my mouse pointer?
Thanks,  AlexanderOriol Gual 

[EMAIL PROTECTED] wrote:  
Hi, What I do to validate a form, is somethig like this:mx:Script ![CDATA[ private function handleValid(eventObj:ValidationResultEvent) : void  {
   if(eventObj.type==ValidationResultEvent.VALID ) {formValid = true;   } else {formValid = false;   }   } private function sendForm() : void
{  if(formValid) {//do whatever you have to do to send the form} else {alert.show(Form is not valid!,Alert);}

}private var formValid : Boolean = false;]]/mx:Scriptmx:StringValidator source={inputText} property=text minLength=3 maxLength=20 
trigger={inputText} triggerEvent=change
 valid=handleValid(event) invalid=handleValid(event)/ mx:Formmx:FormItem label=Input some text required=true direction=horizontal fontWeight=bold textAlign=left
  mx:TextInput id=inputText width=80 maxChars=20//mx:FormItem/mx:Form
mx:Button id=fromButton label=Send form click=sendForm()/ 
When the user inputs some text in the textinput the validation occurs automatically ( trigger={inputText} triggerEvent=change) and the function handleValid is called. Then, when clicking the button if the variable formValid it's true we can send the form. 
By the way, I have a question, what is the meaning of the models with flex 2 and forms? Because they're declared in the examples but the validators don't use them.Hope this helps,Oriol
  
2006/4/2, Dreamer 

[EMAIL PROTECTED]:  

Alex  Alex, you can put the data be validated in a model.like this:mx:Model id=orderemail{
email.text }/email//email is a textInput controller's
 id/mx:Modelthen define a validator: mx:EmailValidator field=order.email/then write a function in the script tag: function confirmOrder(): Void {
if (mx.validators.Validator.isStructureValid(this, 'order')) {mx.controls.Alert.show(Success!!);addMember();}else
 {mx.controls.Alert.show(Please enter valid data in the fields with errors and try again., Problem);}}Peace,Dreamerin china 

[EMAIL PROTECTED]2006-04-02=== 2006-04-02 01:37:17 £º===Hi Mike,I understand the login, but how do I reference the validation?
I mean what would actually go where you have validation is success.I'm not an actionscrip expert! I'm a cfforever guy ;-).Alexander--- In 
flexcoders@yahoogroups.com, Dreamer [EMAIL PROTECTED] wrote: Alex 
 Alex,you can write a function,like that.if(validation is success) addMember();elsealert(invalid input!!!);
Peace, Dreamer [EMAIL PROTECTED]  2006-04-01 === 2006-04-01 18:32:22 £º===
  Hello,  In a signup form, when I click the submit button I would like for all the validation to happen 

[flexcoders] Re: BETA 2: How to validate a form before actually submitting

2006-04-03 Thread Alex Alex
Hi Oriol,

This *sounds* a lot better though I am getting these errors at 
compile time.

1::Implicit coercion of a value of type 'String' to an unrelated 
type 'mx.events:ValidationResultEvent (this error appears twice)

2::Comparison between a value with static 
type 'mx.validators:StringValidator' and a possibly unrelated 
type 'String' (this error appears twice)

3::Access of undefined property 'alert'

I'm not such of an actionscript guy, but I'll get there sooner or 
later. Thanks again.

Alex

--- In flexcoders@yahoogroups.com, Oriol Gual [EMAIL PROTECTED] 
wrote:

 Hi Alexander,
 
 Thanks to your observation I've came to a better solution:
 
 mx:Script
 ![CDATA[
 import mx.events.ValidationResultEvent;
 
 private function checkValidators() : Boolean
 {
 stringvalidation  = stringvalidator.validate().type;
 stringvalidation2 = stringvalidator2.validate().type;
 if ( (stringvalidator == ValidationResultEvent.VALID)  
(stringvalidator2
 == ValidationResultEvent.VALID) ) {
 return true;
 } else {
 return false;
 }
 }
 
 private function sendForm() : void
 {
 if(checkValidators()) {
 //do whatever you have to do to send the form
 } else {
 alert.show(Form is not valid!,Alert);
 }
 }
 private var stringvalidation : ValidationResultEvent;
 private var stringvalidation2 : ValidationResultEvent;
 ]]
 /mx:Script
 
 mx:StringValidator id=stringvalidator source={inputText}
 property=text minLength=3 maxLength=20
  trigger={inputText} triggerEvent=change/
 
 mx:StringValidator id=stringvalidator2 source={inputText}
 property=text minLength=3 maxLength=20
  trigger={inputText2} triggerEvent=change/
 
 mx:Form
 mx:FormItem label=Input some text required=true 
direction=horizontal
 fontWeight=bold textAlign=left
 mx:TextInput id=inputText width=80 maxChars=20/
  /mx:FormItem
 mx:FormItem label=Input some other text required=true
 direction=horizontal fontWeight=bold textAlign=left
 mx:TextInput id=inputText2 width=80 maxChars=20/
  /mx:FormItem
 /mx:Form
 mx:Button id=fromButton label=Send form click=sendForm()/
 
 
 Some explanation and changes:
 
 - Removed the valid/invalid properties of the validators.
 - Added an id for each one.
 - Instead of doing this: if ( (stringvalidator.validate ().type==
 ValidationResultEvent.VALID)  (stringvalidator2.validate().type==
 ValidationResultEvent.VALID) ) which is also correct, I think it's 
better to
 do it with the variables, and then evaluating them, because you 
validate all
 the fields (and the tooltip errors are shown, like you wanted 
Alexander),
 the other way if the first fails the other fields won't be 
validated.
 
 Hope this helps,
 
 Oriol
 
 2006/4/3, Alexander Tsoukias [EMAIL PROTECTED]:
 
   While this does the trick, what if I have 3 inputs? While one 
passes the
  validation the sendForm() will be executed while the other 2 
inputs are
  still unvalidated? I want to make sure all of them are validated 
before
  executing sendForm().
 
  BTW, cool about the on change validation. One thing though... is 
there a
  way to make the error tooltip show up programatically instead of 
having to
  hover over my mouse pointer?
 
  Thanks,
  Alexander
 
  *Oriol Gual  [EMAIL PROTECTED]* wrote:
 
  Hi,
 
  What I do to validate a form, is somethig like this:
 
  mx:Script
  ![CDATA[
 
  private function handleValid(eventObj:ValidationResultEvent) : 
void
  {
  if(eventObj.type==ValidationResultEvent.VALID ) {
  formValid = true;
  } else {
  formValid = false;
  }
  }
  private function sendForm() : void
  {
  if(formValid) {
  //do whatever you have to do to send the form
  } else {
  alert.show(Form is not valid!,Alert);
  }
  }
 
  private var formValid : Boolean = false;
 
  ]]
  /mx:Script
 
  mx:StringValidator source={inputText} property=text 
minLength=3
  maxLength=20
   trigger={inputText} triggerEvent=change valid=handleValid
(event)
  invalid=handleValid(event)/
 
  mx:Form
  mx:FormItem label=Input some text required=true
  direction=horizontal fontWeight=bold textAlign=left
  mx:TextInput id=inputText width=80 maxChars=20/
   /mx:FormItem
  /mx:Form
  mx:Button id=fromButton label=Send form click=sendForm()/
 
  When the user inputs some text in the textinput the validation 
occurs
  automatically ( trigger={inputText} triggerEvent=change) and 
the
  function handleValid is called. Then, when clicking the button 
if the
  variable formValid it's true we can send the form.
 
  By the way, I have a question, what is the meaning of the models 
with flex
  2 and forms? Because they're declared in the examples but the 
validators
  don't use them.
 
  Hope this helps,
 
  Oriol
 
 
  2006/4/2, Dreamer  [EMAIL PROTECTED]:
 
   Alex  Alex,
  
you can put the data be validated in a 
model.like this:
   mx:Model id=order
   email{ email.text }
/email//email is
   a textInput controller's id
  

Re: [flexcoders] Re: BETA 2: How to validate a form before actually submitting

2006-04-02 Thread Dreamer
Alex  Alex,

 you can put the data be validated in a model.like this:
mx:Model id=order
email{email.text}/email//email is a 
textInput controller's id
/mx:Model
then define a validator:

   mx:EmailValidator field=order.email/

then write a function in the script tag:

  function confirmOrder(): Void {

if (mx.validators.Validator.isStructureValid(this, 'order')) {
mx.controls.Alert.show(Success!!);
addMember();
  }
else {
mx.controls.Alert.show(Please enter valid data in the fields 
with errors and try again., Problem);
}

}

   
 Peace,
 
Dreamer  in china
[EMAIL PROTECTED]
  2006-04-02

=== 2006-04-02 01:37:17 :===

Hi Mike,

I understand the login, but how do I reference the validation?

I mean what would actually go where you have validation is success.

I'm not an actionscrip expert! I'm a cfforever guy ;-).

Alexander


--- In flexcoders@yahoogroups.com, Dreamer [EMAIL PROTECTED] wrote:

 Alex  Alex,
 
  you can write a function,like that.
  
  if(validation is success)
  addMember();
  else
  alert(invalid input!!!);
 
    
  Peace,
   
 Dreamer
 [EMAIL PROTECTED]
   2006-04-01
 
 === 2006-04-01 18:32:22 :===
 
 
 Hello,
 
 In a signup form, when I click the submit button I would like for 
all 
 the validation to happen and then actually hit the addMember() 
 function.
 
 But if a form fails the validation how can I prevent the 
execution of 
 addMember().
 
 Thanks,
 Alexander
 
 
 
 
 
 --
 Flexcoders Mailing List
 FAQ: 
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 Search Archives: http://www.mail-archive.com/flexcoders%
40yahoogroups.com 
 Yahoo! Groups Links
 
 
 
  
 
 
 
 
 = = = = = = = = = = = = = = = = = = = =
  
 
  







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links



 

= = = = = = = = = = = = = = = = = = = =


 



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 


[flexcoders] Re: BETA 2: How to validate a form before actually submitting

2006-04-01 Thread Alex Alex
Hi Mike,

I understand the login, but how do I reference the validation?

I mean what would actually go where you have validation is success.

I'm not an actionscrip expert! I'm a cfforever guy ;-).

Alexander


--- In flexcoders@yahoogroups.com, Dreamer [EMAIL PROTECTED] wrote:

 Alex  Alex,
 
   you can write a function,like that.
   
   if(validation is success)
   addMember();
   else
   alert(invalid input!!!);
 
 ¡¡
  Peace,

 Dreamer
 [EMAIL PROTECTED]
 2006-04-01
 
 === 2006-04-01 18:32:22 £º===
 
 
 Hello,
 
 In a signup form, when I click the submit button I would like for 
all 
 the validation to happen and then actually hit the addMember() 
 function.
 
 But if a form fails the validation how can I prevent the 
execution of 
 addMember().
 
 Thanks,
 Alexander
 
 
 
 
 
 --
 Flexcoders Mailing List
 FAQ: 
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 Search Archives: http://www.mail-archive.com/flexcoders%
40yahoogroups.com 
 Yahoo! Groups Links
 
 
 
  
 
 
 
 
 = = = = = = = = = = = = = = = = = = = =
   
 
 ¡¡







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 




Re: [flexcoders] Re: BETA 2: How to validate a form before actually submitting

2006-04-01 Thread Manish Jethani
On 4/1/06, Alex  Alex [EMAIL PROTECTED] wrote:

 I mean what would actually go where you have validation is success.

In Flex 1.5 you used to be able to call isStructureValid() on the data
model.  I don't know how it is in Flex 2.0

Mansih


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 




Re: [flexcoders] Re: BETA 2: How to validate a form before actually submitting

2006-04-01 Thread Marc Archuleta
Here's a code snippet that works in Flex 1.5. It may
need some refactoring for version 2. This code uses
the StringValidator. If Validator.isStructureValid
fails, myfield_ti will be highlighted in red and there
will be a little message saying it's a required field
(or whatever the particular validator has by default,
or a custom message you setup). Check the
documentation for other types of validators you can
use or extend one of them and do your own logic. You
can set custom messages in attributes of the validator
or through a custom validator.   

 MXML 

mx:Model id=myModel
myFieldName{myfield_ti.text}/myFieldName
/mx:Model

mx:StringValidator field=myModel.myFieldName/

 ACTIONSCRIPT 
// do this in the method that runs when you click your
submit button

Validator.enable(this,myModel.myFieldName);
if (Validator.isStructureValid(this, 'myModel')) {
//add code here to submit form 
}



--- Alex  Alex [EMAIL PROTECTED] wrote:

 Hi Mike,
 
 I understand the login, but how do I reference the
 validation?
 
 I mean what would actually go where you have
 validation is success.
 
 I'm not an actionscrip expert! I'm a cfforever guy
 ;-).
 
 Alexander
 
 
 --- In flexcoders@yahoogroups.com, Dreamer
 [EMAIL PROTECTED] wrote:
 
  Alex  Alex,
  
  you can write a function,like that.
  
  if(validation is success)
  addMember();
  else
  alert(invalid input!!!);
  
  ��������������
   Peace,
   
 
����������������Dreamer
 
[EMAIL PROTECTED]
 
��������������������2006-04-01
  
  === 2006-04-01 18:32:22 ��===
  
  
  Hello,
  
  In a signup form, when I click the submit button
 I would like for 
 all 
  the validation to happen and then actually hit
 the addMember() 
  function.
  
  But if a form fails the validation how can I
 prevent the 
 execution of 
  addMember().
  
  Thanks,
  Alexander
  
  
  
  
  
  --
  Flexcoders Mailing List
  FAQ: 

http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
  Search Archives:
 http://www.mail-archive.com/flexcoders%
 40yahoogroups.com 
  Yahoo! Groups Links
  
  
  
   
  
  
  
  
  = = = = = = = = = = = = = = = = = = = =
  
  
  ��
 
 
 
 
 
 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/