This Plugin => JQuery Validation Plugin
What I'm trying to do its to validation some input fileds, that will contain a NameServer which has the next structure ns1.hoster.com y got a pattern to detect if the user it writing a domain ^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$ that i put into de input but a friend told me that can be erase if you inspect the element and recommend to use JS.
I found this on StackOverflow it's not exact what I want but would be great if someone can tel me anything helpful.
Custom Validation Rule
//custom validation rule
$.validator.addMethod("customemail",
function(value, element) {
return /^([a-zA-Z0-9_.-+])+\@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/.test(value);
},
"Sorry, I've enabled very strict email validation"
);
Adding Rules
rules: {
email: {
required: {
depends:function(){
$(this).val($.trim($(this).val()));
return true;
}
},
customemail: true
},
Ali Doruk Baykal
Senior Sofware Developer and Team Leader
Hi Ariel,
I think using validation libraries like JQuery Validation is not the problem here. You can always use these libraries for front-end validations. I think your friend is pointing out that anyone can disable front-end scripting and can pass whatever they want to your backend. So the main point is to make the same validation on the server-side too. It is best practice to do the validations on both front-end and back-end.