[semi-OT]simulating onSubmit in post

Martin Baxter mb.userev at harbourhosting.co.uk
Wed Feb 24 04:39:17 EST 2010

Hi Devin,

In the url instanced below, unless I'm misunderstanding what you are
trying to do, if you make a properly formed POST direct to
someurl.htm?loadpage, direct from a script or a stack for instance, the
onSubmit event in the html form is almost certainly irrelevant, because
it is only triggered in the browser when the user clicks the submit
element, and wouldn't apply in other cases.

Have you experienced some issue that makes you think it is relevant?

javascript validation can stop the form data being POSTed by the browser
if something is wrong with user input or whatever, but you would bypass
that by POSTing directly to the action url.

Javascript pre-validation can manipulate the form data or perhaps set
headers before it allows the POST action, and that might conceivably be
relevant to it being accepted as valid by the action url. But it isn't
very likely and in any case you should be able to figure the details out
by reading the javascript to see what happens.

Any serious validation will invariably be done by the script the data is
POSTed *to* (the action url), unless the author is naive. Javascript
validation (pre-validation) is really only useful for catching obvious
data entry errors for purposes of user-friendliness.

Martin Baxter

Devin Asay wrote:
> Hi folks,
> I'm trying to teach myself how to GET and POST submissions to URLs that
> provide simple web services, like word lookups and the like. I
> understand the basic concept pretty well and can successfully "harvest"
> data from various web forms. But I notice that often POST method forms
> use JavaScript calls to validate data in the forms before submitting it
> to the server. It might look like this:
> <form method="POST" action="someurl.htm?loadpage" name="formname"
> onSubmit="return Validate(this);">
> In this case the Validate function is defined in the header and
> basically returns true if the submit came from the form "formname" AND
> all of the fields are filled in. It returns false if either of these
> conditions is not met.
> My question: Is it possible to construct a post command and/or header
> combination that simulates this onSubmit event returning true? This is
> basically an academic exercise to help me understand how JS and forms
> work, and how Rev's GET and POST functionality works; I'm not planning
> to distribute stacks that do this in any way.
> Regards,
> Devin

I am Not a Number, I am a free NaN

More information about the Use-livecode mailing list