forked from binary-com/binary-static
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathform_validation.js
More file actions
85 lines (77 loc) · 2.62 KB
/
form_validation.js
File metadata and controls
85 lines (77 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
//
//
// This script contains various functions used by our forms.
// NOTE: Since you might not find reference to these functions within our javascripts you might delete some stuff from here without cleaning up forms.
//
function clearInputErrorField(id) {
var errorfield = document.getElementById(id);
if (errorfield) {
// we need to create a brand new passage element and replace to the existing one.
// IE6 does not treat null/empty string as empty innerHTML (which means it will appear at the IE browswer)
var parentNode = errorfield.parentNode;
if (parentNode) {
var passage = document.createElement('p');
passage.id = errorfield.id;
passage.className = errorfield.className;
parentNode.replaceChild(passage, errorfield);
return passage;
}
return errorfield;
}
}
function set_account_broker_code()
{
// for auth account, we do not reset the broker
var actype = $('#actype');
if (actype && (actype.attr('value') == 'authaccount' || actype.attr('value') == 'virtual'))
{
return false;
}
var residence = $('#residence');
if (residence.length)
{
var broker_code;
var linkfrom = document.getElementById('linkfrom');
var regexp_affiliate = new RegExp('^\\D+\\d+$');
if (linkfrom && regexp_affiliate.test(linkfrom.value))
{
linkfrom.value = linkfrom.value.replace(/\s+/g,'');
var grep_affiliate = new RegExp('^\\D+');
broker_code = grep_affiliate.exec(linkfrom.value);
}
else
{
//get the broker value from the selection residence's option
broker_code = $('#residence').find('option:selected').attr('class');
}
// after we get the broker code correctly then we assign the open account server and the hidden broker value
var form_object = $('#openAccForm');
// returned error message and redirect client back to account opening form page if there is connection error
if (form_object.length && broker_code !== '')
{
var hidden_broker = $('#broker');
hidden_broker.attr('value', broker_code);
}
}
}
function swithTabIfError(IsErrorFound)
{
if (IsErrorFound)
{
$('.errorfield').each(function ()
{
if (this.innerHTML.length > 0)
{
MenuContent.trigger({
'content_id': $(this).parents('[id*=-content]').attr('id')
});
}
});
return 1;
}
else
{
return 0;
}
}