In my form I am using drop down for showing day, month, year. can you help me to validate the date. I have to validate the entered age is greater than 15. also checking leap year
I am using a javascript function (F) (jquery )which uses 3 select values selected by the user to calculates a value - R(result)
R is a number ranging from (1 through 9), (11) and (22);
I need 2 extra steps one before the calculation and one after.
a. Before calculation takes place:
Make sure all three select values are changed before function(F) takes place. If not prompt the user with a notice ( create dom element/ I am using jquery)
b. After the value R is calculated show an element corresponding to the result e.g. if R is 1 show an element ( a predetermined "link" element corresponding to each result value)
thanks a lot.
After adding the new facebook like button to my page, it no longer validates using XHTML strict. The two errors I come across are:
All of the "meta property" tags say that "there is no attribute "property""
All of the variables used in the like button line are listed that there are no attributes for it. The line is as follows:
<fb:like href="http://www.pampamanta.org" layout="button_count" show_faces="false" width="120" action="like" font="arial" colorscheme="light"></fb:like>
Hi,
I'm working on deploying a web application written in C# with ASP.Net Application services databases.
The application runs fine on the development machine.
Windows Server 2003 has been built to test the application.
The database has been scripted across using MS SQL Server GUI.
ASP.Net application services tables were created using an utility.
The connection strings are stored in the web.config and connectionStrings.config.
The application connects to the database successfully, but then it times out after 10 seconds.
Hello, I've got a little problem here.
I've got the following rule for one of my fields:
StartDate: {
required: isDelayed,
dateRU: true
}
isDelayed() returns false, so I guess StartDate field should be optional. However if I check it inside my dateRU method:
$.validator.addMethod(
"dateRU",
function(value, element) {
return this.optional(element) || isValidDate($.trim(value));
},
"Date is incorrect"
);
this.optional(element) always returns false for StartDate. I can't figure out what's wrong. Any ideas?
UPD. Does optional() returns true only if element is not required AND IS EMPTY? 'Cause that may be my problem.
I have a requirement here to build a comment-like app in my django project, the app has a view to receive a submitted form process it and return the errors to where ever it came from. I finally managed to get it to work, but I have doubt for the way am using it might be wrong since am passing the entire validated form in the session.
below is the code
comment/templatetags/comment.py
@register.inclusion_tag('comment/form.html', takes_context=True)
def comment_form(context, model, object_id, next):
"""
comment_form()
is responsible for rendering the comment form
"""
# clear sessions from variable incase it was found
content_type = ContentType.objects.get_for_model(model)
try:
request = context['request']
if request.session.get('comment_form', False):
form = CommentForm(request.session['comment_form'])
form.fields['content_type'].initial = 15
form.fields['object_id'].initial = 2
form.fields['next'].initial = next
else:
form = CommentForm(initial={
'content_type' : content_type.id,
'object_id' : object_id,
'next' : next
})
except Exception as e:
logging.error(str(e))
form = None
return {
'form' : form
}
comment/view.py
def save_comment(request):
"""
save_comment:
"""
if request.method == 'POST':
# clear sessions from variable incase it was found
if request.session.get('comment_form', False):
del request.session['comment_form']
form = CommentForm(request.POST)
if form.is_valid():
obj = form.save(commit=False)
if request.user.is_authenticated():
obj.created_by = request.user
obj.save()
messages.info(request, _('Your comment has been posted.'))
return redirect(form.data.get('next'))
else:
request.session['comment_form'] = request.POST
return redirect(form.data.get('next'))
else:
raise Http404
the usage is by loading the template tag and firing
{% comment_form article article.id article.get_absolute_url %}
my doubt is if am doing the correct approach or not by passing the validated form to the session. Would that be a problem? security risk? performance issues?
Please advise
Update
In response to Pol question. The reason why I went with this approach is because comment form is handled in a separate app. In my scenario, I render objects such as article and all I do is invoke the templatetag to render the form. What would be an alternative approach for my case?
You also shared with me the django comment app, which am aware of but the client am working with requires a lot of complex work to be done in the comment app thats why am working on a new one.
We have a requirement where we need to allow users to dynamically create custom reports that will run against our database and return sets of data. It would be something similar to this: http://www.marcuswhitworth.com/2009/12/dynamic-linq-with-expression-trees/ but would ultimately contain the ability to create more complicated logic.
I believe LINQ to Entities might possibly allow us to do something like we're attempting to achieve. I should note that these reports are going to need to run against multiple tables. Can anyone point me in the right direction for something like this? Has anyone done anything similar with LINQ to Entities?
I have 'n' number of textbox on a form, after the user enters a value in a textbox, i need to validate its not a duplicate in the other textboxes.
Ex :
Textbox[0] : 1
Textbox[1] : 2
Textbox[2] : 3
Textbox[4] : 1
For this example it should alert saying that '1' have entered twice.
Let me know what to be done.
What is the meaning of the following error message?How can I use the EnableClienTValidation()?
Error 3 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'EnableClientValidation' and no extension method 'EnableClientValidation' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?) c:\Dev\DEV\test3\Code\MvcUI\Views\Customer\Create.aspx 11 13 MvcUI
I have reference the following:`" type="text/javascript"
<script src="<%=Url.Content("~/Scripts/jquery.validate.js")%>" type="text/javascript"></script>
<script src="<%= Url.Content("~/Scripts/MicrosoftAjax.js")%>" type="text/javascript"></script>
<script src="<%= Url.Content("~/Scripts/MicrosoftMvcAjax.js")%>" type="text/javascript"></script>
<script src="<%= Url.Content("~/Scripts/MicrosoftMvcJQueryValidation.js" )%>" type="text/javascript"></script>
`
I not getting the desired effect from a script. I want the password to contain A-Z, a-z, 0-9, and special chars.
A-Z
a-z
0-9 2
special chars 2
string length = 8
So I want to force the user to use at least 2 digits and at least 2 special chars. Ok my script works but forces me to use the digits or chars back to back. I don't want that. e.g. password testABC55$$ is valid - but i don't want that.
Instead I want test$ABC5#8 to be valid. So basically the digits/special char can be the same or diff - but must be split up in the string.
PHP CODE:
$uppercase = preg_match('#[A-Z]#', $password);
$lowercase = preg_match('#[a-z]#', $password);
$number = preg_match('#[0-9]#', $password);
$special = preg_match('#[\W]{2,}#', $password);
$length = strlen($password) >= 8;
if(!$uppercase || !$lowercase || !$number || !$special || !$length) {
$errorpw = 'Bad Password';
How to validate a textarea in a form.i.e, it should not be empty or have any new lines and if so raise an alert
<script>
function val()
{
//ifnewline found or blank raise an alert
}
</script>
<form>
<textarea name = "pt_text" rows = "8" cols = "8" class = "input" WRAP ></textarea>
<input type=""button" onclick="val();"
</form>
Thanks
Hi
I have a form field which requires a json object as its value when it is rendered.
When the form is submitted it returns a comma seperated string of ids as its value (not a json string). however if the form does not validate i want to turn this string of ids back into a json string so it will display properly (is uses jquery to render the json object correctly).
how would i do this?
I was thinking of overwriting the form.clean method but when I tried to change self.data['fieldname'] I got the error 'This QueryDict instance is immutable'
and when i tried to change self.cleaned_data['fieldname'] it didn't make a difference to the value of the field.
Thanks
I'm trying to validate the entry of text using Python/tkInter
def validate_text():
return False
text = Entry(textframe, validate="focusout", validatecommand=validate_text)
where validate_text is the function - I've tried always returning False and always returning True and there's no difference in the outcome..? Is there a set of arguments in the function that I need to include?
Edit - changed from NONE to focusout...still not working
Hello,
I am writing an ASP.NET MVC application that combines a set of features from existing applications. The new application is suppose to use UI features and logic created (especially for this purpose) in the existing applications.
For that reason I wanted to create in the existing applications some kind of a "blackbox" that I will be able to drop in my new application along with a matching connection string, and it will work independently, binding data on it's own.
I thought about using partial views, but I am having trouble with passing the model data to it, since the controller of the new application should not know about the model of the existing applications.
I can not use ASP.NET WebForms, since my application should be a "postback-less" application, and ASP.NET AJAX toolkit or frameworks alike are out of the question.
Any help would be greatly appreciated.
Thank you,
Katie
I'm trying to validate a UI change when Enter key is pressed. The UI element is a textbox, which is data binded to a string. My problem is that the data binding hasn't updated TestText when Enter key is Up. It is only updated when I press the button which brings up a message box.
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window, INotifyPropertyChanged
{
String _testText = new StringBuilder("One").ToString();
public string TestText
{
get { return _testText; }
set { if (value != _testText) { _testText = value; OnPropertyChanged("TestText"); } }
}
public Window1()
{
InitializeComponent();
myGrid.DataContext = this;
}
private void OnPropertyChanged(string property)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(property));
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void onKeyUp(object sender, KeyEventArgs e)
{
if (e.Key != System.Windows.Input.Key.Enter) return;
System.Diagnostics.Trace.WriteLine(TestText);
}
private void button1_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show(TestText);
}
}
Window XAML:
Window x:Class="VerificationTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300" KeyUp="onKeyUp"
TextBox XAML:
TextBox Name="myTextBox" Text="{Binding TestText}"
Button XAML:
Button Name="button1" Click="button1_Click"
I am looking to add a custom message before listing my errors for a login page:
"Oops, you forgot to enter the following:" + "Username", "Password" (if both not entered)
or
"Oops, you forgot to enter the following:" + "Username" (if just username not entered)
$(document).ready(function(){
$("#loginForm").validate({
errorLabelContainer: $('#RegisterErrors'),
messages: {
username: "Username",
password: "Password"
}
});
});
With this in my HTML
<div id="RegisterErrors">
I am using this technique to place default input in the text fields as a hint to users.
http://www.dailycoding.com/Posts/default_text_fields_using_simple_jquery_trick.aspx
I would like to also validate the fields using jquery validate.
How can i get the validater to ignore the default input?
i dont know whether am only getting this problem or some one else.
When entering string as input in the quantity filed of addtocart input box it never throws error and it takes as 1. how can i validate it. bcz they already made onclick function on addtocart function.
Please help me to solve this
For the love of God I am not getting this easy code to work! It is always alerting out "null" which means that the string does not match the expression.
var pattern = "^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$";
function isEmailAddress(str) {
str = "[email protected]";
alert(str.match(pattern));
return str.match(pattern);
}
I have a required attribute that used with resources:
public class ArticleInput : InputBase
{
[Required(ErrorMessageResourceType = typeof(ArticleResources), ErrorMessageResourceName = "Body_Validation_Required")]
public string Body { get; set; }
}
I want to specify the resources be convention, like this:
public class ArticleInput : InputBase
{
[Required2]
public string Body { get; set; }
}
Basically, Required2 implements the values based on this data:
ErrorMessageResourceType = typeof(ClassNameWithoutInput + Resources); // ArticleResources
ErrorMessageResourceName = typeof(PropertyName + "_Validation_Required"); // Body_Validation_Required
Is there any way to achieve something like this? maybe I need to implement a new ValidationAttribute.
i have a simple form and when user enters all the information and hits the submit botton than a panel should open just a width of 200px and height of 100px inside the same window. which should have two fields one is captcha image and a text box and a check botton and if captcha code is right than panel should automatically close and redirect to another page just like facebook .
all the details of the panel is saved on another php file.
I'm trying to construct a regex to screen valid part and/or serial numbers in combination, with ranges.
A valid part number is a two alpha, three digit pattern or /[A-z]{2}\d{3}/
i.e. aa123 or ZZ443 etc...
A valid serial number is a five digit pattern, or /\d{5}/
13245 or 31234 and so on.
That part isn't the problem. I want combinations and ranges to be valid as well:
12345, ab123,ab234-ab245, 12346 - 12349 - the ultimate goal. Ranges and/or series of part and/or serial numbers in any combination. Note that spaces are optional when specifying a range or after a comma in a series. Note that a range of part numbers has the same two letter combination on both sides of the range (i.e. ab123 - ab239)
I have been wrestling with this expression for two days now, and haven't come up with anything better than this:
/^(?:[A-z]{2}\d{3}[, ]*)|(?:\d{5}[, ]*)|(?:([A-z]{2})\d{3} ?- ?\4\d{3}[, ]*)|(?:\d{5} ?- ?\d{5}[, ]*)$/
...
My Regex-Fu is weak.
Google Maps newbie (GIS newbie), I'm looking at a solution to map an overlay (number of polygons) on-top of Google maps and wondered if using a KML file was a viable solution?
Basically, I have a number of address (address data) that I will pass to our internal GIS system, the GIS system hands me back a KML file (one file with a number of different locations) and then I draw the polygon using the KML Layering options:
https://developers.google.com/maps/documentation/javascript/layers
Sound like a viable solution?
Cheers