-
1. Re: Spry textfield validation with XHR submit
dfmatt May 13, 2009 2:30 AM (in response to Phil_W)You will need to catch the form before it gets submitted.
You can add an 'onsubmit' to your <form> tag which points to a function that will validate the data.
Something like this, <form action="page.asp" onsubmit="return validateForm(this)">
And then you need a function which will validate all of the inputs.
I haven't used the spry form validation bits before, but if there is a method you can call on that which validates your form then you can just run that in your function.
If your function does a return(0) then the form will not submit
-
2. Re: Spry textfield validation with XHR submit
Arnout Kazemier May 13, 2009 2:35 AM (in response to Phil_W)Did you check out this example:?
http://labs.adobe.com/technologies/spry/samples/form_submission/Submit_and_Validate_Form.p hp.html
also
instead of doing:
success = success + 'string';
you can just do:
success += 'String';
-
3. Re: Spry textfield validation with XHR submit
Phil_W May 13, 2009 2:20 PM (in response to Arnout Kazemier)Hi,
I've checked the samples.
The standard submit example validates the fields the XHR example does not.
I added the following code from the XHR sample
if (Spry.Widget.Form.validate('register') == true)
{
Spry.Utils.submitForm('register', registerResponse);
}However Spry.Widget.Form.validate('register') always returns true regardless of the state of the Spry validation
Any more ideas to get the XHR submit to recognise the state of the Spry validation for the form
Cheers
Phil
-
4. Re: Spry textfield validation with XHR submit
Phil_W May 13, 2009 3:41 PM (in response to Phil_W)Hi,
Ok solved.
Attach the register function (with code in previous post) to the head rather than end of the body section and it works fine.
Cheers
Phil


