diff -ru TYPO3core_orig_cvs/t3lib/jsfunc.validateform.js TYPO3core_testing/t3lib/jsfunc.validateform.js
--- TYPO3core_orig_cvs/t3lib/jsfunc.validateform.js	2005-10-21 10:06:58.000000000 +0200
+++ TYPO3core_testing/t3lib/jsfunc.validateform.js	2005-11-23 19:39:22.000000000 +0100
@@ -25,7 +25,11 @@


 function validateForm(theFormname,theFieldlist,goodMess,badMess,emailMess)	{
-	if (document[theFormname] && theFieldlist)	{
+	var formname = document[theFormname];
+	if (!formname) {
+		formname = document.getElementById(theFormname);
+	}
+	if (formname && theFieldlist)	{
 		var index=1;
 		var theField = split(theFieldlist, ",", index);
 		var msg="";
@@ -58,8 +62,8 @@
 			index++;
 			theLabel = unescape(split(theFieldlist, ",", index));
 			theField = unescape(theField);
-			if (document[theFormname][theField])	{
-				var fObj = document[theFormname][theField];
+			if (formname[theField])	{
+				var fObj = formname[theField];
 				var type=fObj.type;
 				if (!fObj.type)	{
 					type="radio";
diff -ru TYPO3core_orig_cvs/tslib/class.tslib_content.php TYPO3core_testing/tslib/class.tslib_content.php
--- TYPO3core_orig_cvs/tslib/class.tslib_content.php	2005-11-23 16:57:16.000000000 +0100
+++ TYPO3core_testing/tslib/class.tslib_content.php	2005-11-23 19:47:38.000000000 +0100
@@ -1621,10 +1621,23 @@
 		$fieldname_hashArray = Array();
 		$cc = 0;

-			// Formname;
-		$formname = $GLOBALS['TSFE']->uniqueHash();
-		if (ctype_digit($formname{0}))	{	// form name must start with a letter
-			$formname = 'a'.$formname;
+		$xhtmlStrict = t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2',$GLOBALS['TSFE']->config['config']['doctype']);
+			// Formname
+		if ($conf['formName'])	{
+			$formname = $this->cleanFormName($conf['formName']);
+		} else {
+			$formname = $GLOBALS['TSFE']->uniqueHash();
+			$formname = 'a'.$formname;	// form name has to start with a letter to reach XHTML compliance
+		}
+
+		if (isset($conf['fieldPrefix']))	{
+			if ($conf['fieldPrefix'])	{
+				$prefix = $this->cleanFormName($conf['fieldPrefix']);
+			} else {
+				$prefix = '';
+			}
+		} else {
+			$prefix = $formname;
 		}

 		foreach($dataArr as $val)	{
@@ -1651,7 +1664,7 @@
 				$typeParts = explode('=',$fParts[0]);
 				$confData['type'] = trim(strtolower(end($typeParts)));
 				if (count($typeParts)==1)	{
-					$confData['fieldname'] = substr(ereg_replace('[^a-zA-Z0-9_]','',str_replace(' ','_',trim($parts[0]))),0,30);
+					$confData['fieldname'] = $this->cleanFormName($parts[0]);
 					if (strtolower(ereg_replace('[^[:alnum:]]','',$confData['fieldname']))=='email')	{$confData['fieldname']='email';}
 						// Duplicate fieldnames resolved
 					if (isset($fieldname_hashArray[md5($confData['fieldname'])]))	{
@@ -1684,9 +1697,15 @@
 					if (strcmp('',$addParams))	$addParams=' '.$addParams;
 				} else $addParams='';

+				if ($conf['dontMd5FieldNames']) {
+					$fName = $confData['fieldname'];
+				} else {
+					$fName = md5($confData['fieldname']);
+				}
+
 					// Accessibility: Set id = fieldname attribute:
-				if ($conf['accessibility'])	{
-					$elementIdAttribute = ' id="'.$formname.'_'.md5($confData['fieldname']).'"';
+				if ($conf['accessibility'] || $xhtmlStrict)	{
+					$elementIdAttribute = ' id="'.$prefix.$fName.'"';
 				} else {
 					$elementIdAttribute = '';
 				}
@@ -1781,6 +1800,9 @@
 					break;
 					case 'radio':
 						$option='';
+						if ($conf['accessibility'])	{
+							$option.='<fieldset'.$elementIdAttribute.'><legend>'.$confData['label'].'</legend>';
+						}
 						$valueParts = explode(',',$parts[2]);
 						$items=array();		// Where the items will be
 						$default='';
@@ -1800,10 +1822,23 @@
 						$default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], $default);
 							// Create the select-box:
 						for($a=0;$a<count($items);$a++)	{
-							$option.= '<input type="radio" name="'.$confData['fieldname'].'"'.$elementIdAttribute.' value="'.$items[$a][1].'"'.(!strcmp($items[$a][1],$default)?' checked="checked"':'').''.$addParams.' />';
-							$option.= $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']);
+							$radioId = $prefix.$fName.$this->cleanFormName($items[$a][0]);
+							if ($conf['accessibility'])	{
+								$radioLabelIdAttribute = ' id="'.$radioId.'"';
+							} else {
+								$radioLabelIdAttribute = '';
+							}
+							$option.= '<input type="radio" name="'.$confData['fieldname'].'"'.$radioLabelIdAttribute.' value="'.$items[$a][1].'"'.(!strcmp($items[$a][1],$default)?' checked="checked"':'').''.$addParams.' />';
+							if ($conf['accessibility'])	{
+								$option.= '<label for="'.$radioId.'">' . $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']) . '</label>';
+							} else {
+								$option.= $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']);
+							}
 							$option.= '<br />';
 						}
+						if ($conf['accessibility'])	{
+							$option.='</fieldset>';
+						}
 						$fieldCode = $option;
 					break;
 					case 'hidden':
@@ -1885,8 +1920,8 @@

 						// Field:
 					$fieldLabel = $confData['label'];
-					if ($conf['accessibility'])	{
-						$fieldLabel = '<label for="'.$formname.'_'.md5($confData['fieldname']).'">'.$fieldLabel.'</label>';
+					if ($conf['accessibility'] && $confData['type'] != 'label')	{
+						$fieldLabel = '<label for="'.$prefix.$fName.'">'.$fieldLabel.'</label>';
 					}

 						// Getting template code:
@@ -2003,7 +2038,7 @@
 		$content = Array(
 			'<form'.
 				' action="'.htmlspecialchars($action).'"'.
-				' name="'.$formname.'"'.
+				' id="'.$formname.'"'.
 				' enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'"'.
 				' method="'.($conf['method']?$conf['method']:'post').'"'.
 				($theTarget ? ' target="'.$theTarget.'"' : '').
@@ -2771,6 +2806,20 @@
 		return $altParam;
 	}

+	/**
+	 * removes forbidden characters and spaces from name/id attributes in the form tag and formfields
+	 *
+	 * @param	string		Input string
+	 * @return	string		the cleaned string
+	 * @see FORM()
+	 */
+	function cleanFormName($name) {
+			// turn data[x][y] into data:x:y:
+		$name = preg_replace('/\[|\]\[?/',':',trim($name));
+			// remove illegal chars like _
+		return preg_replace('#[^:a-zA-Z0-9]#','',$name);
+	}
+


