Skip to content

Instantly share code, notes, and snippets.

@WilCF
Created May 26, 2015 21:00
Show Gist options
  • Save WilCF/1dd5a76558a1c5358f41 to your computer and use it in GitHub Desktop.
Save WilCF/1dd5a76558a1c5358f41 to your computer and use it in GitHub Desktop.
JQuery to disallow similar textbox input submissions
require(['jquery-noconflict'], function(jQuery) {
//Ensure MooTools is where it must be
Window.implement('$', function(el, nc){
return document.id(el, nc, this.document);
});
var $ = window.jQuery;
$(document).ready(function(){
$("input.submit").click(function(e){
var bad_answers = false;
$(".cml.jsawesome").each(function() {
var one = $(this).find('input.one');
var two = $(this).find('input.two');
if($(two).val().length > 0 && $(one).val().length > 0){
if ($(one).val() === $(two).val()) {
bad_answers = true;
}
}
})
if (bad_answers) {
alert('Values Should Not Match');
return false;
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment