Home | Site map   
  Home Products Downloads Support Contacts
 
 

HowTo: Highlight required form fields

This article will show you how to let your form user know, all at once and before sending the information, about each required field that hasn't been filed in. Each required field will be highlighted in yellow while it is empty.

Steps:

Open PHPRunner project and proceed to Visual Editor tab
In "Edit as" settings check off needed fields as Required Field

Build your PHPRunner project and view generated files in Windows Explorer
Open with text editor commonfunctions.php file which located in Output directory in Include folder
Go to Function BuildEditControl and find the following code snippets:

ASPRunner Example
if fformat=EDIT_FORMAT_TEXT_FIELD or fformat=EDIT_FORMAT_TIME then
if IsDateFieldType(ttype) then
   response.Write "<input type=""hidden"" name=""" & ctype & """ value=""date" &_
      EDIT_DATE_SIMPLE & """>" & GetDateEdit(field,value,0,secondfield,edit)
Else
   response.Write "<input type=""text"" name=""" & cfield & """ " &_
      GetEditParams(field,"") & " value=""" & my_htmlspecialchars(value) & """>"
end if

PHPRunner Example
if($format==EDIT_FORMAT_TEXT_FIELD || $format==EDIT_FORMAT_TIME)
{
if(IsDateFieldType($type))
  echo '<input type="hidden" name="'.$ctype.'" value="date'.EDIT_DATE_SIMPLE.'">'.
  GetDateEdit($field,$value,0,$secondfield,$edit);
else
  echo '<input type="text" name="'.$cfield.'" '.GetEditParams($field).
  'value="'.htmlspecialchars($value).'">';
}

Replace the code with:

ASPRunner Example
if fformat=EDIT_FORMAT_TEXT_FIELD or fformat=EDIT_FORMAT_TIME then
if IsDateFieldType(ttype) then
   response.Write "<input type=""hidden"" name=""" & ctype & """ value=""date" &_
     EDIT_DATE_SIMPLE & """>" & GetDateEdit(field,value,0,secondfield,edit)
end if
if (IsRequired(field)) then
   response.Write "<input type=""text"" name=""value" & secondfield & """" & GetEditParams(field) &_
     " value=""" & htmlspecialchars(value) &_
     """onchange=""if(this.value.length==0) this.style.background='Yellow'; else this.style.background='White';""" &_
     "onkeyup=""if(this.value.length==0) this.style.background='Yellow'; else this.style.background='White';"">" &_
     "<script language=javascript> if(editform.value" & secondfield & ".value.length==0) editform.value" & secondfield &_
     ".style.background=""Yellow""; else editform.value" & secondfield & ".style.background=""White""; </script>"
Else
   response.Write "<input type=""text"" name=""" & cfield & """ " &_
     GetEditParams(field,"") & " value=""" & my_htmlspecialchars(value) & """>"
end if

PHPRunner Example
if($format==EDIT_FORMAT_TEXT_FIELD || $format==EDIT_FORMAT_TIME)
{
if(IsDateFieldType($type))
  echo '<input type="hidden" name="'.$ctype.'" value="date'.EDIT_DATE_SIMPLE.'">'
  .GetDateEdit($field,$value,0,$secondfield,$edit);
if (IsRequired($field))
  echo '<input type="text" name="value'.$secondfield.'" '.GetEditParams($field).
  ' value="'.htmlspecialchars($value).
  '"onchange="if(this.value.length==0) this.style.background=\'Yellow\'; else this.style.background=\'White\';"'.
  'onkeyup="if(this.value.length==0) this.style.background=\'Yellow\'; else this.style.background=\'White\';">
  <script language=javascript>
  if(editform.value'.$secondfield.'.value.length==0) editform.value'.$secondfield.'.style.background=\'Yellow\'; else editform.value'.$secondfield.'.style.background=\'White\';
  </script>
  ';
else
  echo '<input type="text" name="'.$cfield.'" '.GetEditParams($field).' value="'.htmlspecialchars($value).'">';
}

The result will be the following:

Applies to:
ASPRunner Pro
PHPRunner

Back to top

 
 

Home | Products | Downloads | Support | Contacts

  ©1999 - 2006 XLineSoft. All rights reserved. All comments send to webmaster@xlinesoft.com