zain zain - 3 months ago 10
Javascript Question

How to use java script to validate text box with popup notification?

I'm using this java script code to validate a text box but when popup appears and the user pressed okay it returns to page and submit button disabled so when click submit no action occurs, any ideas ?

if (document.getElementById('Title').value == "") {
alert('Please fill mobile number');
$(document).ready(function () {
$("form").submit(function (e) {
e.preventDefault(); //prevent default form submit

});
});
}


this line is the problem:

e.preventDefault();


I need substitutes please

Answer
 $("form").submit(function (e) {
     e.preventDefault();  
     if (document.getElementById('Title').value == "") {
        alert('Please fill mobile number');
        return false;
     }
});

in your code, validation and form submission working on separate.