-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathall-jquery-functions-events.php
257 lines (194 loc) · 8.14 KB
/
all-jquery-functions-events.php
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
SELECTORS:
1) #using class name : $('.class_name')
2) #using ID name : $('#id_name')
3) #uing tag name : $('tagname')
4) #using ele & class : $("p.class_name")
5) #all elements : $("a[href]") || $("a[target='_blank']") || $(":button")
GETTING VALUES:
1) var x = $("#id_name").val();
2) var x = $(".class_name").val();
3) var x = $(this).val();
4) var x = $(this).attr('attribute-name');
5) var str = $("form").serialize(); || $(this).serialize();
6) var checked_val = $("input:checkbox[name=check_coll]:checked").val(); #checkbox value
7) var radio_val = $("input:radio[name=status]:checked").val(); #radio value
8) var x = $("input:checkbox").val();
9) $('#id').each(function(){ var x = $(this).val(); });
10) $('.class').each(function(){ var x = $(this).val(); });
EVENTS:
#MOUSE EVENTS:
<!-- Click Statrt -->
1) $("#id").click(function(){ }); #using id name
2) $(".class_name").click(function(){ }); #using class name
3) $(document).on("click", ".edit_listcontact", function(){ }); #using class name
4) $(document).on("click","#upd_user_info_btn",function(){ }); #using id name
<!-- Click End -->
<!-- Double Click -->
1) $("p").dblclick(function(){ });
2) $("#id").dblclick(function(){ });
3) $(".class").dblclick(function(){ });
<!-- Double Click End -->
<!-- Mouse Enter -->
1) $("p").mouseenter(function(){ });
2) $("#id").mouseenter(function(){ });
3) $(".class").mouseenter(function(){ });
<!-- End Mouse Enter -->
<!-- Mouse leave -->
1) $("p").mouseleave(function(){ });
2) $("#id").mouseleave(function(){ });
3) $(".class").mouseleave(function(){ });
<!-- End Mouse Leave -->
<!-- Mouse Down -->
1) $("p").mousedown(function(){ });
2) $("#id").mousedown(function(){ });
3) $(".class").mousedown(function(){ });
<!-- End Mouse Down -->
<!-- Mouse leave -->
1) $("p").mouseup(function(){ });
2) $("#id").mouseup(function(){ });
3) $(".class").mouseup(function(){ });
<!-- End Mouse Leave -->
<!-- Hover -->
1) $("p").hover(function(){ });
2) $("#id").hover(function(){ });
3) $(".class").hover(function(){ });
<!-- End Hover -->
#FORM EVENTS:
<!-- Form submit -->
1) $("form").submit(function(){ });
2) $("#form_id").submit(function(){ });
3) $(".form_class").submit(function(){ });
<!-- End Submit -->
<!-- Change -->
# when an input field is changed || value enter and remove
1) $("input").change(function(){ });
2) $("#input_id").change(function(){ });
3) $(".input_class").change(function(){ });
<!-- End Change -->
<!-- Focus -->
#when the form field gets focus || enter into form input filed
1) $("input").focus(function(){ });
2) $("#id").focus(function(){ });
3) $(".class").focus(function(){ });
<!-- End Focus -->
<!-- Blur -->
#when the form field lose focus || leave form input filed
1) $("input").blur(function(){ });
2) $("#id").blur(function(){ });
3) $(".class").blur(function(){ });
<!-- End Blur -->
#KEYBOARD EVENTS:
<!-- Key Down -->
# when <input> field when a keyboard key is pressed down.
1) $("input").keydown(function(){ });
2) $("#input_id").keydown(function(){ });
3) $(".input_class").keydown(function(){ });
<!-- End Key Down -->
<!-- Key Up -->
# when an <input> field when a keyboard key is released.
1) $("input").keyup(function(){ });
2) $("#input_id").keyup(function(){ });
3) $(".input_class").keyup(function(){ });
<!-- End Key Up -->
<!-- Key Press -->
# when <input> field when a keyboard key is pressed.
1) $("input").keypress(function(){ });
2) $("#input_id").keypress(function(){ });
3) $(".input_class").keypress(function(){ });
<!-- End Key Press -->
#MULTIPLE EVENTS AT A TIME:
<!-- on -->
1) $("input").on('click','blur', function(){ });
2) $("#input_id").on('keypress','hover', function(){ });
3) $(".input_class").on('keypress','hover',function(){ });
4) $('#account_id').on('change', function () { });
5) $(document).on("keyup","#id-name",function(){});
5) $(document).on("keyup",".class-name",function(){});
7) $("selector").on({
mouseenter: function(){ $(this).css("background-color", "lightgray"); },
mouseleave: function(){ $(this).css("background-color", "lightblue"); },
click: function(){ $(this).css("background-color", "yellow"); }
});
<!-- end on -->
VALIDATIONS:
#Empty Check:
var xid = $("#id").val();
if((xid == 0) || (xid == '') || (xid == undefined) || (xid == null)){
alert('empty');
}
#ALLOW ONLY NUMBERS:
$(document).on("keyup",".allowNumOnly",function(){
var val = $(this).val();
if(isNaN(val)){
val = val.replace(/[^0-9\.]/g,'');
}
$(this).val(val);
});
#Mail Validation:
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if(emailReg.test(mail) ){
alert("Valid");
} else {
alert("Invalid");
}
#Mobile Validation:
var mobile = $("#mobile").val();
var filter = /^\d*(?:\.\d{1,2})?$/; || var NumberRegex = /^[0-9]*$/;
if (mobile.test(filter) && mobile.length == 10) {
alert("Valid");
} else {
alert("Invalid");
}
#Validate Dynamic Fileds(Multiple):
var primary_numbers = [];
$("input[name='primary_mobile[]']").each(function() {
var value = $(this).val();
primary_numbers.push(value);
if(value == ""){
alert("Mobile number should not be empty");
} else if(value != '') {
if(value.length < 10){
alert("Mobile number should be 10 digit");
}
}
});
if(primary_numbers != ""){
duplicateNumber = primary_numbers.some((element, index) => {
return primary_numbers.indexOf(element) !== index
});
if(duplicateNumber){
alert("Duplicate numbers should not be allowed!");
}
}
#Checkbox Validation:
if(($('.is_primeMobile:radio:checked').length == 0)){
alert("Please select atleast one primary number");
}
OTHERS:
$('#ultab a[href="#add_contacts"]').click(function(){ });
$("#contact_per_salutation").addClass("errTxtField");
$("#contact_per_salutation").removeClass("errTxtField");
$(document).one('click', closeTooltip);
$(".loader").show();
$("#show_parent_grp").hide();
$(".loader").append();
$('#reporting_to_contact_person').empty();
$('#imagepopup').modal('show');
$('#image-zoom').attr("src",img_path);
$('#users_for_account').append($("<option></option>").attr("value",0).text("Select"));
$('input').on('ifChecked', function(event){ });
$('input').on('ifUnchecked', function(event){ });
$.each(response.products, function(key,value) { });
if(!mailValidation(assistant_email)){}
$("#closepop" ).trigger( "click" );
$(".modal-title").html("Edit Notification");
$("#all_regn_chkd").prop("checked",true);
$('#gst_chk_1').prop('checked', false);
$('input:checkbox.stateBoxClass').each(function () { });
$(".sta_cls").css("display","block");
$(".sta_cls").css("display","none");
$("input[type=radio][name=team_for]:checked").val();
$("#member_designation").keypress(function () { });
$("input[name='gst_chk']").serializeArray();
$("#pan,#company,#address").val('');
var formData = new FormData($("#form-usermanagement")[0]);