Skip to content

Commit b9c39c9

Browse files
committed
Limiting Username Input!
Limiting Username Input!
1 parent 0eb2e3f commit b9c39c9

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

tmpl/assets/registerloginajax.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@ jQuery(document).ready(function () {
1919
jQuery('#registration_ input#openview').val(jQuery(this).val());
2020
}
2121
});
22+
23+
2224
jQuery("#registration_form").validate({
25+
rules: {
26+
'jform[username]': {
27+
required: true,
28+
noSpecialChars:true
29+
}
30+
},
2331
submitHandler: function () {
2432
var submit = jQuery('#register_submit');
2533
jQuery.ajax({
@@ -70,4 +78,9 @@ jQuery(document).ready(function () {
7078
return false;
7179
}
7280
});
81+
82+
jQuery.validator.addMethod("noSpecialChars", function(value, element) {
83+
return this.optional(element) || /^[a-z0-9]+$/i.test(value);
84+
}, "Only letters and numbers allowed.");
85+
7386
});

tmpl/default.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,11 @@
207207
'terms[]': {
208208
required: true,
209209
maxlength: 2
210-
}
210+
},
211+
'jform[username]': {
212+
required: true,
213+
noSpecialChars:true
214+
}
211215
},
212216
messages: {
213217
'terms[]': {
@@ -217,6 +221,12 @@
217221
},
218222
});
219223
<?php } ?>
224+
225+
jQuery.validator.addMethod("noSpecialChars", function(value, element) {
226+
return this.optional(element) || /^[a-z0-9]+$/i.test(value);
227+
}, "Only letters and numbers allowed.");
228+
229+
220230
}(jQuery))
221231

222232
function previewpass() {

0 commit comments

Comments
 (0)