Kbase P18393: How to validate user input on client side?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  31/01/2003 |
|
Status: Unverified
GOAL:
How to validate user input on client side?
FACT(s) (Environment):
Webspeed 3.x
FIX:
Client side validations for user input can be done with JavaScript.
Here is an example:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD>
<META NAME="AUTHOR" CONTENT="Your Name">
<TITLE>WebSpeed Script</TITLE>
<SCRIPT LANGUAGE="SpeedScript">
/* Create an unnamed pool to store all the widgets created by this procedure.
This is a good default which assures that this procedure's triggers and
internal procedures will execute in this procedure's storage, and that
proper cleanup will occur on deletion of the procedure. */
CREATE WIDGET-POOL.
</SCRIPT>
<script language="JavaScript">
function checkHiddenFields()
{
if (document.fmain.cc.value=="") {
// user didn't entered the CC field
alert( "CC field is blank" );
}
else
if (document.fmain.first1.value=="" ) {
// user didn't entered the First1 field
alert( "First1 field is blank" );
}
else {
// the user entered all the information
alert( "Now I can submit." );
document.fmain.submit();
}
}
</script>
</HEAD>
<BODY>
<form name=fmain method=POST>
First1<input type=text name=first1 value="`get-field('first1')`" >
<br>
CC<input type=text name=cc value="`get-field('cc')`" >
<br>
<input type="button" name=b_submit value="go" onclick="checkHiddenFields()">
</form>
Submit Confirmation `string( ETIME )`.
</BODY>
</HTML>