BUG 6900 Solved the validation of field email in dynaform
The problem was solved modificating the validation of field email
This commit is contained in:
@@ -770,7 +770,13 @@ function G_Text( form, element, name, type )
|
||||
var pat=/^[\w\_\-\.çñ]{2,255}@[\w\_\-]{2,255}\.[a-z]{1,3}\.?[a-z]{0,3}$/;
|
||||
if(!pat.test(this.element.value))
|
||||
{
|
||||
this.element.className=this.element.className.split(" ")[0]+" FormFieldInvalid";
|
||||
if(this.required=="0"&&this.element.value=="") {
|
||||
this.element.className=this.element.className.split(" ")[0]+" FormFieldContent";
|
||||
}
|
||||
else {
|
||||
this.element.className=this.element.className.split(" ")[0]+" FormFieldInvalid";
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1887,16 +1893,42 @@ var validateForm = function(sRequiredFields) {
|
||||
invalid_fields.push(aRequiredFields[i].label);
|
||||
vtext1.failed();
|
||||
} else {
|
||||
vtext1.passed();
|
||||
vtext1.passedsed();
|
||||
}
|
||||
break;
|
||||
case 'text':
|
||||
|
||||
var vtext = new input(getField(aRequiredFields[i].name));
|
||||
|
||||
if(getField(aRequiredFields[i].name).value==''){
|
||||
invalid_fields.push(aRequiredFields[i].label);
|
||||
vtext.failed();
|
||||
if(aRequiredFields[i].validate=="Email"&&aRequiredFields[i].required=='0'){
|
||||
vtext.normal();
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
invalid_fields.push(aRequiredFields[i].label);
|
||||
vtext.failed();
|
||||
}
|
||||
|
||||
} else {
|
||||
vtext.passed();
|
||||
|
||||
if(aRequiredFields[i].validate=="Email") {
|
||||
var email = getField(aRequiredFields[i].name);
|
||||
//var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
|
||||
var filter = /^[\w\_\-\.çñ]{2,255}@[\w\_\-]{2,255}\.[a-z]{1,3}\.?[a-z]{0,3}$/;
|
||||
if (!filter.test(email.value)&&email.value!="") {
|
||||
invalid_fields.push(aRequiredFields[i].label);
|
||||
vtext.failed();
|
||||
email.focus();
|
||||
}
|
||||
else {
|
||||
vtext.passed();
|
||||
}
|
||||
}
|
||||
else {
|
||||
vtext.passed();
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ class Form extends XmlForm
|
||||
{
|
||||
/***
|
||||
* This section was added for store the current used template.
|
||||
*/
|
||||
*/
|
||||
$tmp_var = explode('/', $template);
|
||||
if( is_array($tmp_var) ){
|
||||
$tmp_var = $tmp_var[sizeof($tmp_var)-1];
|
||||
|
||||
@@ -4165,15 +4165,25 @@ class XmlForm
|
||||
$field->language = $this->language;
|
||||
$this->fields [$field->name] = $field;
|
||||
}
|
||||
|
||||
//echo var_dump($xmlNode [$k]->attributes["validate"]);
|
||||
|
||||
if (isset ( $xmlNode [$k]->attributes ['required'] )) {
|
||||
// the fields or xml nodes with a required attribute are put in an array that is passed to the view file
|
||||
$isEditMode = isset($xmlNode[$k]->attributes['mode']) && $xmlNode[$k]->attributes['mode'] == 'view' ? false: true;
|
||||
|
||||
if ($xmlNode [$k]->attributes ['required'] == 1 && $isEditMode && $this->mode != 'view')
|
||||
$this->requiredFields [] = array ('name' => $field->name, 'type' => $xmlNode [$k]->attributes ['type'], 'label' => trim ( $field->label ) );
|
||||
}
|
||||
if ($xmlNode [$k]->attributes ['required'] == 1 && $isEditMode && $this->mode != 'view') {
|
||||
$this->requiredFields [] = array ('name' => $field->name, 'type' => $xmlNode [$k]->attributes ['type'], 'label' => trim ( $field->label ), 'validate' => trim ( $field->validate ),'required' => trim ( $field->required ) );
|
||||
}
|
||||
else {
|
||||
$isEditMode = isset($xmlNode[$k]->attributes['mode']) && $xmlNode[$k]->attributes['mode'] == 'view' ? false: true;
|
||||
if ($xmlNode [$k]->attributes ['validate'] == "Email" && $isEditMode && $this->mode != 'view') {
|
||||
$this->requiredFields [] = array ('name' => $field->name, 'type' => $xmlNode [$k]->attributes ['type'], 'label' => trim ( $field->label ), 'validate' => trim ( $field->validate ),'required' => trim ( $field->required ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$oJSON = new Services_JSON ( );
|
||||
|
||||
Reference in New Issue
Block a user