developer155
Programmer
Hi,
I have a asp button on the page(submit button) and I added onclick cleint side even to it. The onclick event calls Validate() function that validates user input before form can be submitted. Everything is fine expect when if user leaves a field out and JS brings up messgae box to alert the user to enter the value, when user click OK in the message box the form submits! It should not obviously
Here is my code and thanks for any help!!!
Button:
<input type="button" id="listBtn" name="listBtn" value="Submit" class="btn" runat="server" onclick="validateList();" />
function validateList() {
var errorMsg = "";
var name = get('listName');
//var table = get('chooseTableInput');
var table = get('chooseTableList2');
if (name.value == ''){
name.className = 'err';
errorMsg += " - enter a name\n";
}
if (table.value == ''){
table.className = 'err';
errorMsg += " - choose a table\n";
}
// display errMsg or submit the form
if (errorMsg != "") {
alert('Please correct the following:\n\n' + errorMsg);
return false;
}
else {
return true;
}
}
I have a asp button on the page(submit button) and I added onclick cleint side even to it. The onclick event calls Validate() function that validates user input before form can be submitted. Everything is fine expect when if user leaves a field out and JS brings up messgae box to alert the user to enter the value, when user click OK in the message box the form submits! It should not obviously
Here is my code and thanks for any help!!!
Button:
<input type="button" id="listBtn" name="listBtn" value="Submit" class="btn" runat="server" onclick="validateList();" />
function validateList() {
var errorMsg = "";
var name = get('listName');
//var table = get('chooseTableInput');
var table = get('chooseTableList2');
if (name.value == ''){
name.className = 'err';
errorMsg += " - enter a name\n";
}
if (table.value == ''){
table.className = 'err';
errorMsg += " - choose a table\n";
}
// display errMsg or submit the form
if (errorMsg != "") {
alert('Please correct the following:\n\n' + errorMsg);
return false;
}
else {
return true;
}
}