44 Posts
1 month ago

I would like to compare two text fields, if they are the same, don't allow the user to save the form using the submit button. I added code to the button in the Javascript are in the field. It did not work:

document.getElementById("My_submit_button").onclic = function() {myFunction()};

function myFunction(){



if (name1 === name2){

alert("Please change the names.");

return false;


return true;


I also tried this too in the submit button javascript area. The preventDefault() would prevent the submit to work but then it just would never work even after I changed the field text and pressed the submit button again.



var name1=$('#name1').val();

var name2=$('#name2').val();

if (name1 === name2){

alert("Please change names.");





Get a Book for SEBLOD