Hey Guys,
I am new to PHP and know nothing of java scripts. I have to build a web page where user enters login information at the time of registration. I have taken help of a PHP tool to generate the required scripts. Now in that I have to incorporate a functionality to check the password length and give appropiate message if password is too short. I think I could enter this functionality through javascripts but I don't know how. I am attaching the file in which the PHP scripts are written. Please help me out.

Attachments
<?php
define("EW_PAGE_ID", "add", TRUE); // Page ID
define("EW_TABLE_NAME", 'login_table', TRUE);
?>
<?php 
session_start(); // Initialize session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg50.php" ?>
<?php include "ewmysql50.php" ?>
<?php include "phpfn50.php" ?>
<?php include "login_tableinfo.php" ?>
<?php include "userfn50.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php

// Open connection to the database
$conn = ew_Connect();
?>
<?php
$Security = new cAdvancedSecurity();
?>
<?php
if (!$Security->IsLoggedIn()) $Security->AutoLogin();
$Security->LoadCurrentUserLevel('login_table');
if (!$Security->IsLoggedIn()) {
	$Security->SaveLastUrl();
	Page_Terminate("login.php");
}
if (!$Security->CanAdd()) {
	$Security->SaveLastUrl();
	Page_Terminate("login_tablelist.php");
}
if ($Security->IsLoggedIn() && $Security->CurrentUserID() == "") {
	$_SESSION[EW_SESSION_MESSAGE] = "You do not have the right permission to view the page";
	Page_Terminate("login.php");
}
?>
<?php

// Common page loading event (in userfn*.php)
Page_Loading();
?>
<?php

// Page load event, used in current page
Page_Load();
?>
<?php
$login_table->Export = @$_GET["export"]; // Get export parameter
$sExport = $login_table->Export; // Get export parameter, used in header
$sExportFile = $login_table->TableVar; // Get export file, used in header
?>
<?php

// Load key values from QueryString
$bCopy = TRUE;
if (@$_GET["user_id"] != "") {
  $login_table->user_id->setQueryStringValue($_GET["user_id"]);
} else {
  $bCopy = FALSE;
}

// Create form object
$objForm = new cFormObj();

// Process form if post back
if (@$_POST["a_add"] <> "") {
  $login_table->CurrentAction = $_POST["a_add"]; // Get form action
  LoadFormValues(); // Load form values
} else { // Not post back
  if ($bCopy) {
    $login_table->CurrentAction = "C"; // Copy Record
  } else {
    $login_table->CurrentAction = "I"; // Display Blank Record
    LoadDefaultValues(); // Load default values
  }
}

// Perform action based on action code
switch ($login_table->CurrentAction) {
  case "I": // Blank record, no action required
		break;
  case "C": // Copy an existing record
   if (!LoadRow()) { // Load record based on key
      $_SESSION[EW_SESSION_MESSAGE] = "No records found"; // No record found
      Page_Terminate($login_table->getReturnUrl()); // Clean up and return
    }
		break;
  case "A": // ' Add new record
		$login_table->SendEmail = TRUE; // Send email on add success
    if (AddRow()) { // Add successful
      $_SESSION[EW_SESSION_MESSAGE] = "Add New Record Successful"; // Set up success message
      Page_Terminate($login_table->KeyUrl($login_table->getReturnUrl())); // Clean up and return
    } else {
      RestoreFormValues(); // Add failed, restore form values
    }
}

// Render row based on row type
$login_table->RowType = EW_ROWTYPE_ADD;  // Render add type
RenderRow();
?>
<?php 
$logquery="SELECT MAX(user_id) FROM login_table;";
$uidresult=mysql_query($logquery);
$uidresult_row=mysql_fetch_row($uidresult);
$log=$uidresult_row[0]+1;
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--
var EW_PAGE_ID = "add"; // Page id

//-->
</script>
<script type="text/javascript">
<!--

function ew_ValidateForm(fobj) {
	if (fobj.a_confirm && fobj.a_confirm.value == "F")
		return true;
	var i, elm, aelm, infix;
	var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
	for (i=0; i<rowcnt; i++) {
		infix = (fobj.key_count) ? String(i+1) : "";
		elm = fobj.elements["x" + infix + "_user_name"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - User Name"))
				return false;
		}
		elm = fobj.elements["x" + infix + "_password"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - Password"))
				return false;
		}
		elm = fobj.elements["x" + infix + "_user_id"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - User ID"))
				return false;
		}
		elm = fobj.elements["x" + infix + "_user_id"];
		if (elm && !ew_CheckInteger(elm.value)) {
			if (!ew_OnError(elm, "Incorrect integer - User ID"))
				return false; 
		}
		elm = fobj.elements["x" + infix + "_user_access_rights"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - User Access Rights"))
				return false;
		}
	}
	return true;
}

//-->
</script>
<script type="text/javascript">
<!--
var ew_DHTMLEditors = [];

//-->
</script>
<script type="text/javascript">
<!--
var ew_MultiPagePage = "Page"; // multi-page Page Text
var ew_MultiPageOf = "of"; // multi-page Of Text
var ew_MultiPagePrev = "Prev"; // multi-page Prev Text
var ew_MultiPageNext = "Next"; // multi-page Next Text

//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->

</script>
<p><span class="phpmaker">Add: User Information<br><br><a href="<?php echo $login_table->getReturnUrl() ?>">Go Back</a></span></p>
<?php
if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Mesasge in Session, display
?>
<p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
<?php
  $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
}
?>
<form name="flogin_tableadd" id="flogin_tableadd" action="login_tableadd.php" method="post" onSubmit="return ew_ValidateForm(this);">
<p>
<input type="hidden" name="a_add" id="a_add" value="A">
<table class="ewTable">
  <tr class="ewTableRow">
    <td class="ewTableHeader">User Name<span class='ewmsg'>&nbsp;*</span></td>
    <td<?php echo $login_table->user_name->CellAttributes() ?>><span id="cb_x_user_name">
<input type="text" name="x_user_name" id="x_user_name" title="" size="30" maxlength="20" value="<?php echo $login_table->user_name->EditValue ?>"<?php echo $login_table->user_name->EditAttributes() ?>>
</span></td>
  </tr>
  <tr class="ewTableAltRow">
    <td class="ewTableHeader">Password<span class='ewmsg'>&nbsp;*</span></td>
    <td<?php echo $login_table->password->CellAttributes() ?>><span id="cb_x_password">
<input type="password" name="x_password" id="x_password" title="" value="<?php echo $login_table->password->EditValue ?>" size="30" maxlength="20"<?php echo $login_table->password->EditAttributes() ?>>
</span></td>
  </tr>
   <span id="cb_x_user_id">
<?php if (!$Security->IsAdmin() && $Security->IsLoggedIn()) { // Non system admin ?>
<input type="hidden" name="x_user_id" id="x_user_id" value="<?php echo $log ?>">
<?php } else { ?>
<input type="hidden" name="x_user_id" id="x_user_id" title="" size="30" maxlength="10" value="<?php echo $log ?>"<?php echo $login_table->user_id->EditAttributes() ?>>
<?php } ?>
</span>
  <tr class="ewTableAltRow">
    <td class="ewTableHeader">User Access Rights<span class='ewmsg'>&nbsp;*</span></td>
    <td<?php echo $login_table->user_access_rights->CellAttributes() ?>><span id="cb_x_user_access_rights">
<?php if (!$Security->IsAdmin() && $Security->IsLoggedIn()) { // Non system admin ?>
<div<?php echo $login_table->user_access_rights->ViewAttributes() ?>><?php echo $login_table->user_access_rights->EditValue ?></div>
<?php } else { ?>
<select id="x_user_access_rights" name="x_user_access_rights"<?php echo $login_table->user_access_rights->EditAttributes() ?>>
<!--option value="">Please Select</option-->
<?php
if (is_array($login_table->user_access_rights->EditValue)) {
	$arwrk = $login_table->user_access_rights->EditValue;
	$rowswrk = count($arwrk);
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($login_table->user_access_rights->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected" : "";	
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
			}
}
?>
</select>
<?php } ?>
</span></td>
  </tr>
</table>
<p>
<input type="submit" name="btnAction" id="btnAction" value="    Add    ">
</form>
<script language="JavaScript" type="text/javascript">
<!--

// Write your table-specific startup script here
// document.write("page loaded");
//-->

</script>
<?php include "footer.php" ?>
<?php

// If control is passed here, simply terminate the page without redirect
Page_Terminate();

// -----------------------------------------------------------------
//  Subroutine Page_Terminate
//  - called when exit page
//  - clean up connection and objects
//  - if url specified, redirect to url, otherwise end response
function Page_Terminate($url = "") {
	global $conn;

	// Page unload event, used in current page
	Page_Unload();

	// Global page unloaded event (in userfn*.php)
	Page_Unloaded();

	 // Close Connection
	$conn->Close();

	// Go to url if specified
	if ($url <> "") {
		ob_end_clean();
		header("Location: $url");
	}
	exit();
}
?>
<?php

// Load default values
function LoadDefaultValues() {
	global $login_table;
}
?>
<?php

// Load form values
function LoadFormValues() {

	// Load from form
	global $objForm, $login_table;
	$login_table->user_name->setFormValue($objForm->GetValue("x_user_name"));
	$login_table->password->setFormValue($objForm->GetValue("x_password"));
	$login_table->user_id->setFormValue($objForm->GetValue("x_user_id"));
	$login_table->user_access_rights->setFormValue($objForm->GetValue("x_user_access_rights"));
}

// Restore form values
function RestoreFormValues() {
	global $login_table;
	$login_table->user_name->CurrentValue = $login_table->user_name->FormValue;
	$login_table->password->CurrentValue = $login_table->passw

This is how you get the length of a string.

var stringlen = stringvarname.length;

BTW: its all html when it hits the browser

Hi,

Replace the ew_ValidateForm javascript function with

function ew_ValidateForm(fobj) {
	if (fobj.a_confirm && fobj.a_confirm.value == "F")
		return true;
	var i, elm, aelm, infix;
	var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
	for (i=0; i<rowcnt; i++) {
		infix = (fobj.key_count) ? String(i+1) : "";
		elm = fobj.elements["x" + infix + "_user_name"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - User Name"))
				return false;
		}
		elm = fobj.elements["x" + infix + "_password"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - Password"))
				return false;
		}
		//Added by vivek Rawat here to check the length of pasword
		minlength=6;
		if (elm)
		{
			if(elm.value.length < minlength)
			{
				alert("Password should have minimum "+minlength+" characters");
				return false;
			}
		}
		//end added by vivek rawat
		elm = fobj.elements["x" + infix + "_user_id"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - User ID"))
				return false;
		}
		elm = fobj.elements["x" + infix + "_user_id"];
		if (elm && !ew_CheckInteger(elm.value)) {
			if (!ew_OnError(elm, "Incorrect integer - User ID"))
				return false; 
		}
		elm = fobj.elements["x" + infix + "_user_access_rights"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - User Access Rights"))
				return false;
		}
	}
	return true;
}

Check for the code that I have added.
in the block
//Added by vivek Rawat here to check the length of pasword

This question has already been answered. Start a new discussion instead.