PDA

View Full Version : Client-Side Validation simply does not work on php page


this_is_me
06-30-2009, 01:46 AM
I have a form with file field, text, 2 dropdowns, a set of radio buttons and a text area field.
I started with just validating the text field, nothing else, yet.
the form tag is:
<form action="file_upload_control.php" method="post" enctype="multipart/form-data" name="Auftragsdaten" id="Auftragsdaten" onSubmit="WAValidateNM(document.forms[0].anzahl,'- Invalid number format',1,100,0,'','','.,',document.forms[0].anzahl,1,true)">

But the effect of not inserting any number, is, it jumps to the next page. No validation, no error message, nothing.

I recently updated to VA Toolkit ver. 2.3.5

If I apply DW built-in Form validation behaviour, validation works as expected.

I purchased DataAssists Validation Toolkit in order to use more sophisticated validation. Now it turns out it does even less than DW built-in functionalities.
Any idea?
PS.: I also use an insert record form and DA's file upload, here's part of the code:
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "../dyn/",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "0",
'ResizeWidth' => "0",
'ResizeHeight' => "0",
'ResizeFillColor' => "" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End
?><?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if(isset($_POST["upload"])){
WA_DFP_UploadFiles("WA_UploadResult1", "dateiraufladen", "0", "", "false", $WA_UploadResult1_Params);
}
?>
<?php
// WA Application Builder Insert
if (isset($_POST["upload"])) // Trigger
{
$WA_connection = $myConnection;
$WA_table = "myTable";
$WA_sessionName = "bst_bsID";
$WA_redirectURL = "";
$WA_keepQueryString = true;
$WA_indexField = "bsID";
.....
?>

I am not sure if this has anything to do with client-side validation, but I thought it might be useful to mention.

Ray Borduin
06-30-2009, 06:44 AM
Do you have a url where I can view the error?

Validation toolkit offers advantages over DW validation mostly with its Server Validation. Spry is in fact more full featured than our client validation which is why we have started using spry in place of validation toolkit for client validations in our solutions.

Client validations can be used in conjunction with the DW spry validations and server validations can be applied on top since client validation is really not secure at all since all anyone has to do is turn off javascript to get passed it. That is the functionality that Validation Toolkit offers that is superior to what DW supplies.

Our validation is also more flexible in a lot of ways and can be used in conjunction with spry to help reformat, do contitional validation, or more specific validations that spry may not support, but that is a more advanced concept than I want to go into here.

this_is_me
06-30-2009, 08:53 AM
Well I looked up the document where DA describes the differences between server and client validation. I have not looked into spry validation yet, but thanks for the hint.
I need to check the selection of a menu / list form element and afaik this is not covered by server side validation.
So, what I did until this, I used an old (2002) but nice extension from Yaromat which is free and does an excellent job in client validation.
It checks if the list/menu has been selected by "any but the first entry" which is useful if your first entry is something static like "select please".
In the meantime I used DA Client validation on a very basic html form and it still did not work at all.
http://www.grandits-team.at/Templates/WAVT_Client_Sample.php

This is actually the sample file from WA and it can be sent without filling any field.

Any idea?

Ray Borduin
06-30-2009, 09:07 AM
In the WA extension you would use:

<option value="">select please</option>

and then use required validation on the list. Since the value is blank for that selection it will not pass validation until something else is selected.

this_is_me
06-30-2009, 10:15 AM
You are right.

But my problem was that I did not even come that far with DA's client VT.

Any idea, why the validation does not work at all in the example given above?

Ray Borduin
06-30-2009, 10:59 AM
It seems it didn't copy one of the necessary functions to the header.

If you open and reapply one of the behaviors in the form onSubmit event it would probably correct the error, or you can add the function to the header manually:


function WAFV_GetValueFromInputType(formElement,inputType,t rimWhite) {
var value="";
if (inputType == "select") {
if (formElement.selectedIndex != -1 && formElement.options[formElement.selectedIndex].value && formElement.options[formElement.selectedIndex].value != "") {
value = formElement.options[formElement.selectedIndex].value;
}
}
else if (inputType == "checkbox") {
if (formElement.length) {
for (var x=0; x<formElement.length ; x++) {
if (formElement[x].checked && formElement[x].value!="") {
value = formElement[x].value;
break;
}
}
}
else if (formElement.checked)
value = formElement.value;
}
else if (inputType == "radio") {
if (formElement.length) {
for (var x=0; x<formElement.length; x++) {
if (formElement[x].checked && formElement[x].value!="") {
value = formElement[x].value;
break;
}
}
}
else if (formElement.checked)
value = formElement.value;
}
else if (inputType == "radiogroup") {
for (var x=0; x<formElement.length; x++) {
if (formElement[x].checked && formElement[x].value!="") {
value = formElement[x].value;
break;
}
}
}
else if (inputType == "iRite") {
var theEditor = FCKeditorAPI.GetInstance(formElement.name) ;
value = theEditor.GetXHTML(true);
}
else {
var value = formElement.value;
value=value.replace(/<p>(\&\#160\;)*<\/p>/,"");
}
if (trimWhite) {
value = WAtrimIt(value);
}
return value;
}