Custom Validator - Error message does not display on front end The 2019 Stack Overflow Developer Survey Results Are InHTML5 form required attribute. Set custom validation message?CustomValidator not firing in controlTrigger Enter Event on keypressed JavasccriptDisplay javascript validation messages on the screen not alert messages?MVC4 Custom Validation Error Message with field valueasp.net / JavaScript ClientSide CustomValidation WebMethodWebForm CustomValidator postsback after client validation failsCustom validator in .ascx does not display the error messageMultiple Custom Validators for One ClientValidationFunction Messing up LabelASP.NET Javascript : show all customvalidators messages in one alert
Why is the maximum length of OpenWrt’s root password 8 characters?
Are children permitted to help build the Beis Hamikdash?
If a Druid sees an animal’s corpse, can they wild shape into that animal?
Is "plugging out" electronic devices an American expression?
Landlord wants to switch my lease to a "Land contract" to "get back at the city"
How to save as into a customized destination on macOS?
Why was M87 targetted for the Event Horizon Telescope instead of Sagittarius A*?
Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?
Can a rogue use sneak attack with weapons that have the thrown property even if they are not thrown?
Can one be advised by a professor who is very far away?
Delete all lines which don't have n characters before delimiter
Is there any way to tell whether the shot is going to hit you or not?
Did Section 31 appear in Star Trek: The Next Generation?
Origin of "cooter" meaning "vagina"
Is this app Icon Browser Safe/Legit?
Geography at the pixel level
Write faster on AT24C32
Are there incongruent pythagorean triangles with the same perimeter and same area?
How to support a colleague who finds meetings extremely tiring?
FPGA - DIY Programming
What is the closest word meaning "respect for time / mindful"
What is the motivation for a law requiring 2 parties to consent for recording a conversation
Shouldn't "much" here be used instead of "more"?
What does Linus Torvalds mean when he says that Git "never ever" tracks a file?
Custom Validator - Error message does not display on front end
The 2019 Stack Overflow Developer Survey Results Are InHTML5 form required attribute. Set custom validation message?CustomValidator not firing in controlTrigger Enter Event on keypressed JavasccriptDisplay javascript validation messages on the screen not alert messages?MVC4 Custom Validation Error Message with field valueasp.net / JavaScript ClientSide CustomValidation WebMethodWebForm CustomValidator postsback after client validation failsCustom validator in .ascx does not display the error messageMultiple Custom Validators for One ClientValidationFunction Messing up LabelASP.NET Javascript : show all customvalidators messages in one alert
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am trying to use a CustomValidator to validate entering of a string - po box
Basically, I want the users to avoid typing their postal address in address box for which I have written a function with the regular expression. But the problem is that the error message does not appear though it triggers the function. (I know this because I checked this by placing breakpoints in my Javascript function using Chome developer tools.)
Below is my .ascx file code.
<div class="clearfix">
<asp:Label ID="lblAddress" runat="server" Text="Address" AssociatedControlID="txtAddress"
class="formlabel firstfocus"></asp:Label>
<div class="input">
<asp:TextBox ID="txtAddress" runat="server" CssClass="large" MaxLength="80"></asp:TextBox>
<asp:RequiredFieldValidator ID="valAddress" runat="server" ControlToValidate="txtAddress"
CssClass="error-block" Display="Dynamic" ErrorMessage="<p>Address is required</p>"
SetFocusOnError="True"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="valAddressPOBOX" runat="server" EnableClientScript="true" ValidateEmptyText="true" ErrorMessage="<p>Cannot contain a PO Box number</p>" ClientValidationFunction="AddressPOBoxValidation" ControlToValidate="txtAddress" Display="Dynamic" SetFocusOnError="True"></asp:CustomValidator>
</div>
</div>
The RequiredFieldValidator triggers the error message.
Below is the screenshot showing error message triggered from RequiredFieldValidator

With CustomValidator the trigger happens but the error message does not come up. I have checked on other CustomValidators on the same ascx page and made sure this one has properties no different from them, but still, if I am missing on any visibility property, feel free to correct me.
Below are 2 screenshots to show how the effect of CustomValidator takes place.
Before entering po box

After entering po box (Notice how the gap between address and address 2 increases.)

Coming on to the Javascript side, below is the function
function CheckPOBOXAddress(address)
var poboxPattern = /(p.?s?o?.?s?b.?(ox).?(s
function AddressPOBoxValidation(sender, args)
var address = args.Value;
if (CheckPOBOXAddress(address))
args.IsValid = false;
return;
args.IsValid = false;
javascript asp.net-mvc-4 customvalidator
add a comment |
I am trying to use a CustomValidator to validate entering of a string - po box
Basically, I want the users to avoid typing their postal address in address box for which I have written a function with the regular expression. But the problem is that the error message does not appear though it triggers the function. (I know this because I checked this by placing breakpoints in my Javascript function using Chome developer tools.)
Below is my .ascx file code.
<div class="clearfix">
<asp:Label ID="lblAddress" runat="server" Text="Address" AssociatedControlID="txtAddress"
class="formlabel firstfocus"></asp:Label>
<div class="input">
<asp:TextBox ID="txtAddress" runat="server" CssClass="large" MaxLength="80"></asp:TextBox>
<asp:RequiredFieldValidator ID="valAddress" runat="server" ControlToValidate="txtAddress"
CssClass="error-block" Display="Dynamic" ErrorMessage="<p>Address is required</p>"
SetFocusOnError="True"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="valAddressPOBOX" runat="server" EnableClientScript="true" ValidateEmptyText="true" ErrorMessage="<p>Cannot contain a PO Box number</p>" ClientValidationFunction="AddressPOBoxValidation" ControlToValidate="txtAddress" Display="Dynamic" SetFocusOnError="True"></asp:CustomValidator>
</div>
</div>
The RequiredFieldValidator triggers the error message.
Below is the screenshot showing error message triggered from RequiredFieldValidator

With CustomValidator the trigger happens but the error message does not come up. I have checked on other CustomValidators on the same ascx page and made sure this one has properties no different from them, but still, if I am missing on any visibility property, feel free to correct me.
Below are 2 screenshots to show how the effect of CustomValidator takes place.
Before entering po box

After entering po box (Notice how the gap between address and address 2 increases.)

Coming on to the Javascript side, below is the function
function CheckPOBOXAddress(address)
var poboxPattern = /(p.?s?o?.?s?b.?(ox).?(s
function AddressPOBoxValidation(sender, args)
var address = args.Value;
if (CheckPOBOXAddress(address))
args.IsValid = false;
return;
args.IsValid = false;
javascript asp.net-mvc-4 customvalidator
add a comment |
I am trying to use a CustomValidator to validate entering of a string - po box
Basically, I want the users to avoid typing their postal address in address box for which I have written a function with the regular expression. But the problem is that the error message does not appear though it triggers the function. (I know this because I checked this by placing breakpoints in my Javascript function using Chome developer tools.)
Below is my .ascx file code.
<div class="clearfix">
<asp:Label ID="lblAddress" runat="server" Text="Address" AssociatedControlID="txtAddress"
class="formlabel firstfocus"></asp:Label>
<div class="input">
<asp:TextBox ID="txtAddress" runat="server" CssClass="large" MaxLength="80"></asp:TextBox>
<asp:RequiredFieldValidator ID="valAddress" runat="server" ControlToValidate="txtAddress"
CssClass="error-block" Display="Dynamic" ErrorMessage="<p>Address is required</p>"
SetFocusOnError="True"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="valAddressPOBOX" runat="server" EnableClientScript="true" ValidateEmptyText="true" ErrorMessage="<p>Cannot contain a PO Box number</p>" ClientValidationFunction="AddressPOBoxValidation" ControlToValidate="txtAddress" Display="Dynamic" SetFocusOnError="True"></asp:CustomValidator>
</div>
</div>
The RequiredFieldValidator triggers the error message.
Below is the screenshot showing error message triggered from RequiredFieldValidator

With CustomValidator the trigger happens but the error message does not come up. I have checked on other CustomValidators on the same ascx page and made sure this one has properties no different from them, but still, if I am missing on any visibility property, feel free to correct me.
Below are 2 screenshots to show how the effect of CustomValidator takes place.
Before entering po box

After entering po box (Notice how the gap between address and address 2 increases.)

Coming on to the Javascript side, below is the function
function CheckPOBOXAddress(address)
var poboxPattern = /(p.?s?o?.?s?b.?(ox).?(s
function AddressPOBoxValidation(sender, args)
var address = args.Value;
if (CheckPOBOXAddress(address))
args.IsValid = false;
return;
args.IsValid = false;
javascript asp.net-mvc-4 customvalidator
I am trying to use a CustomValidator to validate entering of a string - po box
Basically, I want the users to avoid typing their postal address in address box for which I have written a function with the regular expression. But the problem is that the error message does not appear though it triggers the function. (I know this because I checked this by placing breakpoints in my Javascript function using Chome developer tools.)
Below is my .ascx file code.
<div class="clearfix">
<asp:Label ID="lblAddress" runat="server" Text="Address" AssociatedControlID="txtAddress"
class="formlabel firstfocus"></asp:Label>
<div class="input">
<asp:TextBox ID="txtAddress" runat="server" CssClass="large" MaxLength="80"></asp:TextBox>
<asp:RequiredFieldValidator ID="valAddress" runat="server" ControlToValidate="txtAddress"
CssClass="error-block" Display="Dynamic" ErrorMessage="<p>Address is required</p>"
SetFocusOnError="True"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="valAddressPOBOX" runat="server" EnableClientScript="true" ValidateEmptyText="true" ErrorMessage="<p>Cannot contain a PO Box number</p>" ClientValidationFunction="AddressPOBoxValidation" ControlToValidate="txtAddress" Display="Dynamic" SetFocusOnError="True"></asp:CustomValidator>
</div>
</div>
The RequiredFieldValidator triggers the error message.
Below is the screenshot showing error message triggered from RequiredFieldValidator

With CustomValidator the trigger happens but the error message does not come up. I have checked on other CustomValidators on the same ascx page and made sure this one has properties no different from them, but still, if I am missing on any visibility property, feel free to correct me.
Below are 2 screenshots to show how the effect of CustomValidator takes place.
Before entering po box

After entering po box (Notice how the gap between address and address 2 increases.)

Coming on to the Javascript side, below is the function
function CheckPOBOXAddress(address)
var poboxPattern = /(p.?s?o?.?s?b.?(ox).?(s
function AddressPOBoxValidation(sender, args)
var address = args.Value;
if (CheckPOBOXAddress(address))
args.IsValid = false;
return;
args.IsValid = false;
javascript asp.net-mvc-4 customvalidator
javascript asp.net-mvc-4 customvalidator
asked Mar 8 at 9:20
Sagittarius009Sagittarius009
18211
18211
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I have found a solution to my problem.After days of trial, error and research this worked for me:
<asp:CustomValidator ID="CustomAddressValidator" runat="server" ClientValidationFunction="CheckAddressValidation" ControlToValidate="txtAddress" CssClass="error-block" Display="Dynamic" SetFocusOnError="True">Cannot contain a PO Box number</asp:CustomValidator>
Also I modified my Javascript into a single function :
function CheckAddressValidation(sender, args) postsoffice)/i;
if (addressPattern.test(address))
args.IsValid = false;
return;
args.IsValid = true;
Lesson - The other part of the CreateProfile.ascx file has Custom Validator in the same format as I posted originally. My superiors feel that Microsoft has done some changes to this probably that is why putting an error message in ErrorMessage tag does not seem to work. Feel free to correct me if I am wrong somewhere. But if you're someone who is stuck in a similar situation, my solution should help.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55060092%2fcustom-validator-error-message-does-not-display-on-front-end%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I have found a solution to my problem.After days of trial, error and research this worked for me:
<asp:CustomValidator ID="CustomAddressValidator" runat="server" ClientValidationFunction="CheckAddressValidation" ControlToValidate="txtAddress" CssClass="error-block" Display="Dynamic" SetFocusOnError="True">Cannot contain a PO Box number</asp:CustomValidator>
Also I modified my Javascript into a single function :
function CheckAddressValidation(sender, args) postsoffice)/i;
if (addressPattern.test(address))
args.IsValid = false;
return;
args.IsValid = true;
Lesson - The other part of the CreateProfile.ascx file has Custom Validator in the same format as I posted originally. My superiors feel that Microsoft has done some changes to this probably that is why putting an error message in ErrorMessage tag does not seem to work. Feel free to correct me if I am wrong somewhere. But if you're someone who is stuck in a similar situation, my solution should help.
add a comment |
I have found a solution to my problem.After days of trial, error and research this worked for me:
<asp:CustomValidator ID="CustomAddressValidator" runat="server" ClientValidationFunction="CheckAddressValidation" ControlToValidate="txtAddress" CssClass="error-block" Display="Dynamic" SetFocusOnError="True">Cannot contain a PO Box number</asp:CustomValidator>
Also I modified my Javascript into a single function :
function CheckAddressValidation(sender, args) postsoffice)/i;
if (addressPattern.test(address))
args.IsValid = false;
return;
args.IsValid = true;
Lesson - The other part of the CreateProfile.ascx file has Custom Validator in the same format as I posted originally. My superiors feel that Microsoft has done some changes to this probably that is why putting an error message in ErrorMessage tag does not seem to work. Feel free to correct me if I am wrong somewhere. But if you're someone who is stuck in a similar situation, my solution should help.
add a comment |
I have found a solution to my problem.After days of trial, error and research this worked for me:
<asp:CustomValidator ID="CustomAddressValidator" runat="server" ClientValidationFunction="CheckAddressValidation" ControlToValidate="txtAddress" CssClass="error-block" Display="Dynamic" SetFocusOnError="True">Cannot contain a PO Box number</asp:CustomValidator>
Also I modified my Javascript into a single function :
function CheckAddressValidation(sender, args) postsoffice)/i;
if (addressPattern.test(address))
args.IsValid = false;
return;
args.IsValid = true;
Lesson - The other part of the CreateProfile.ascx file has Custom Validator in the same format as I posted originally. My superiors feel that Microsoft has done some changes to this probably that is why putting an error message in ErrorMessage tag does not seem to work. Feel free to correct me if I am wrong somewhere. But if you're someone who is stuck in a similar situation, my solution should help.
I have found a solution to my problem.After days of trial, error and research this worked for me:
<asp:CustomValidator ID="CustomAddressValidator" runat="server" ClientValidationFunction="CheckAddressValidation" ControlToValidate="txtAddress" CssClass="error-block" Display="Dynamic" SetFocusOnError="True">Cannot contain a PO Box number</asp:CustomValidator>
Also I modified my Javascript into a single function :
function CheckAddressValidation(sender, args) postsoffice)/i;
if (addressPattern.test(address))
args.IsValid = false;
return;
args.IsValid = true;
Lesson - The other part of the CreateProfile.ascx file has Custom Validator in the same format as I posted originally. My superiors feel that Microsoft has done some changes to this probably that is why putting an error message in ErrorMessage tag does not seem to work. Feel free to correct me if I am wrong somewhere. But if you're someone who is stuck in a similar situation, my solution should help.
answered Apr 3 at 7:18
Sagittarius009Sagittarius009
18211
18211
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55060092%2fcustom-validator-error-message-does-not-display-on-front-end%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown