Is it possible to capture what button was clicked in javascript? I have validation set up but i only want it to validate when a button is clicked and by no other means.
PLEASE NOTE THAT I HAVE 3 TEXTBOXES JUST LIKE THE BELOW. IT'S FOR A PHONE NUMBER ENTRY BROKEN UP INTO 3 TEXT BOXES.
What i would like to do is put and '&&' condition in that javascript if statement saying to set the args.IsValid to false when the button is clicked. Right now it validates on tab key and click of other controls. i just want it to validate on the click of the submit button.
function checkPhNumn(sender, args) {
alert(window.event);
if (phnavalue.value != '' || phnevalue.value != '' || phnnvalue.value != '' ) {
if (phnnvalue.value.length < 4) {
args.IsValid = false;
}
else {
ValidatorEnable(RFV2, true);
ValidatorEnable(RFV3, true);
}
}
}
<ajaxToolkit:ValidatorCalloutExtender ID="ValidatorCalloutExtender4" runat="server"
TargetControlID="phnnVal"
HighlightCssClass="validatorCalloutHighlight"
></ajaxToolkit:ValidatorCalloutExtender>
<asp:TextBox ID="witPhnn" runat="server" MaxLength="4" Width="50pt"></asp:TextBox>
<asp:CustomValidator ID="phnNumValn" runat="server"
Display="None"
ControlToValidate="witPhnn"
ErrorMessage="Please enter a valid phone number."
SetFocusOnError="True"
EnableClientScript="true"
ClientValidationFunction="checkPhNumn"
></asp:CustomValidator>