How do I do a remote validation for jquery.validator.js with a seaside component?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How do I do a remote validation for jquery.validator.js with a seaside component?

Tim Murray

Hi List.

 

I am implementing server side form validations with the jquery.validation.js plugin.

 

There are examples for doing a remote validation of a username to help to ensure that they stay unique within a site.

 

I am now at the point where I want to write a Seaside “component” that will respond to the jquery.validation remote call .

 

I am not sure how to approach this.

 

From the internet, a typical example of a php implementation  looks like this:

 

<?

$email = $_GET['email'];


function isValidEmail($email){
return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email);
}

if($email=="")
{
$errormsg="error1";
}
if(!isValidEmail($email) && $email!="")
{
$errormsg="error2";
}


echo $errormsg;
?>

 

I am wondering if I should intercept these on the initialRequest of my applications custom WATask

 

MyWATask>>initialRequest

 

            "new user registration ajax lookups"

      (aRequest url pathString endsWith: '/jquniqueloginlookup')

                        ifTrue:[?????WHAT DO I DO????].

 

 

Thanks for your time.


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: How do I do a remote validation for jquery.validator.js with a seaside component?

mozillanerd
In a very early project I used server-side Javascript using the same Javascript
code used for the client. Both client and server validator responded with an
object describing the error condition; the object (in JSON) was then interpreted
upon ready().

One very important use case was that of a large form for loan processing which
could be submitted for processing without a browser required to be present.

When a hidden field indicating that client side validation was not used, the
server side validator would take over. The Javascript on the server is mostly
Ecmascript compatible to that in most browsers.

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: How do I do a remote validation for jquery.validator.js with a seaside component?

mozillanerd
In reply to this post by Tim Murray
More info:
I am studying what magritte gives me as it does many things that I implemented
in javascript, jscript and vb (for client and server) way back in 1997:

The rules are very similar. Among the differences is that in the 1997
implementation:
1. The rules were encoded in a subset of javascript and held in the objects
descriptors (in vb).
2. The objects when asked to 'view' generate client side javascript (from the
subset) and if necessary server-side jscript for server side validation in case
that the client does not have javascript or the http request comes from
something other than a browser.
3. The objects hold the model and handle persistance to a relational db. The
objects are aware of collections and links between objects.

Very sophisticated, still in maintenance for a major bank, but soon to be
obsoleted (vb, and .net)

The 'captcha' says 'nostalgia' - very apprpriate


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside