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
 $(document).ready(function() {
            var options = { 
                target:'#errorBox',
                beforeSubmit:  showLoading,
                success: showResponse
            };
            $('#register').ajaxForm(options);
            $('#login').ajaxForm(options);

            $("#errorBox").click(function(){
                $('#errorBox').hide();
            });

        });

        function showResponse(responseText, statusText){
            //clear previous error classes
           //some code

            $("#errorBox").hide();


            //basic registered
            if(responseText.indexOf('OK')!=-1){
                var dynamic = responseText.replace('OK', '?');
                window.location='some location';
            }

            else if (responseText.indexOf('PAY')!=-1){
                var dynamic = responseText.replace('PAY', '');
                window.location='payment location';
            }

            else if (responseText.indexOf('erInput')!=-1){
               //some logic

            }

//more else if stuff


            else {

                $('#errorBox').show();
                $('#errorBox').focus();
            }

        }