We are developing an application where we have a Form to fill by users. Here is the scenario for some fields:
Name : Does not contain numbers like 123 but it can be alpha-numeric like mynangal123 but does not contain special characters
DOB : Does contain specific formats like mm.dd.yyyy or dd/mm/yyy or yyyy/mm/dd etc. doesn't contain alphabets
TAXID : Can be Numeric but not numbers like it can be "123" but not 123 also it can be T-125
Now, as per requirement we have to validate or prompt the user for specific input if he/she did not enter the specific entry. Like if in name User enter 123456 then there should be a messagebox to warn "please enter a valid name"
Restrictions : We have a option of Javascript but its not recommendable in most of scenario so, we need to create a custom validators or something else which will solve our problem.
Please provide some feasible solution for the issue.
Thanks in advance.
Use Custom Validators for this. They provide support for server side & client side validation.
Related
I am turning to Stackoverflow community for a need of critical advice.
It's simple, I want a person to generate a link... and that link will have a button where whoever it is sent to, that person can click yes/no - then return the value.
user 1 > generate link > user 2 > options > return option to user 1
Please can anyone point me in the right direction?
Thanks very much!
All the code you need is in wp-login.php
Generate unique URL (for password reset)
Email URL (or you could just display it)
Set user profile metadata (so you can track it)
If you want to track individual users, then you can either generate a unique url per user, per authored page or perhaps simpler is generate one unique url per page, but check that the user is logged when the unique link is clicked.
Either way you can use that to prevent multiple votes etc
On ASP.Net form, I have a couple input fields which only integer allowed and maximum is 8 digital. right after entering value to the textbox field, it will check the validation. after passing the validation, it will format it with thousand separator. all these happen on fly.
I use Regular Express to do the validation. for example: Regex="^-?\d+{0,8}$".
My question is: I can use this regex to check the input and format it with thousand separator, but when hit save button, it fails on validation(Page.IsValid) because the textbox value will show number with commas(,).
For example: since the field only takes integer,when user enter 20000, it pass regex check at first, but after it format with 20,000 it fails the validation.
So how can I make this work? Thanks.
You can try custom validator
How to: Validate with a Custom Function for ASP.NET Server Controls
I want to validate Status three ways:
Status is a required field: a user must select one status.
If user selects Accept, then:
Qty Rejected should be Disabled
Comments are not compulsory. The user may leave a comment or not.
If user select Reject, then:
The user must put valid range of Qty Rejected, from 1 to 1000 with no non-numeric characters.
Must place a Comment.
How can I achieve this?
Javascript would be your best route for this. An easier route would also be to use jQuery.
Always recheck the information passed to you server side again. I know it seems redundant, but it's for your safety and it provides a better user experience.
You can choose to use javascript/jQuery for all the validations. But you can also use Data Annotations, [Required].
So, using your numbers above:
1) you can use the Data Annotation or JS/jQuery.
2) You can will have to use Data Annotations and/or JS/jQuery. The Data Annotation can handle making sure the input is a number and between 1 and 1000. You will have to use JS/jQuery to check if the Accept/Reject radio button was selected, or disable the Qty Rejected input based on the radio button selection.
3) The comments section can be declared required using JS/jQuery based on the radio button as well.
Info/examples on javascript validation: http://www.w3schools.com/js/js_validation.asp
I've a form with several RequiredFieldValidators.
For now, when a required field isnt completed there s an "*" next to the textbox and then the message in the ValidationSummary. But when there's, for instance, 3 required field uncompleted my ValidationSummary looks like this:
required
required
required
How can I have only one -required?
You can't. Best solution for this is to set the input name (Name, Website, etc) for the error message property. Then the user can intuitively determine which field they need to fill in.
What is the purpose and proper use of the max-length property on text fields?
The application I'm working on limits numeric fields to 6 characters... which doesn't work very well for entering millions of dollars... which is why I'm "fixing" it.
MaxLength Sets or receives the maximum number of characters that a user can enter into a Text control.
EDIT: You do this to prevent having to process something that you know is guaranteed to be wrong.
If you have a text field in your database that is set to 10 characters and the user enters 11 and you don't handle it properly, you cause an exception.
So, just set the maxlength to 10 and you won't have any problems like this.
The Maximum length attribute of a text field and/or textarea effectively limits the user from entering data that is outside the bounds and constraints you have set for your database.
You can use this to make sure users enter in valid SKU numbers, blog titles, ISBN numbers, etc. It is a rudimentary form of data validation.
This doesn't always need to be tied to data validation though.
You could want to limit the length of a string that a user has entered for aesthetic reasons when displaying that data on a page in another location.