I am using DataAnnotations in a project that is a pure C# application, what is the best way to validate my models/documents against the DataAnnotations attributes?
Can anyone help me on how can I validate transaction
example:
transaction = mySqlConn.BeginTransaction(IsolationLevel.ReadCommitted)
If there's still an opened transaction, then the code above will ignore.. How do I know if there was a transaction not yet committed before opening new transaction to avoid Nested Transaction?
I have created a web service with JAX-WS. When the input SOAP message is not well formed or can not be validated, a soap fault is returned automatically to the caller. I dont want the caller to receive this standard SOAP message but i want to create an own custom SOAP fault.
So if the call looks like this (note Envelope1, its not valid):
hello
a default return message is something like this:
S:Client
Couldn't create SOAP message due to exception: unexpected XML tag. expected: {http://schemas.xmlsoap.org/soap/envelope/}Envelope but found: {http://schemas.xmlsoap.org/soap/envelope/}Envelope1
I want the return message to be something like this:
S:Client
My own custom SOAP message!
I have tried to get this to work the whole day, but i cant figure out how to do it. So if someone could help me I would be really glad!
i am new to cakephp 2.x so i dont know how to do this .. i want to login the user from his email address and phone number..what my intention is if the number in database is this "12345" and the user is trying to login through this number "+12345" he can be login into the system.. i have written a code but i dont know how can i use this or to adjust my code within the auth component as the auth component is autometically logging the user ..
here is my controller
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->authenticate = array(
'Authenticate.Cookie' => array(
'fields' => array(
'username' => 'email',
'password' => 'password'
),
'userModel' => 'User',
'scope' => array('User.active' => 1)
),
'Authenticate.MultiColumn' => array(
'fields' => array(
'username' => 'email',
'password' => 'password'
),
'columns' => array('email', 'mobileNo'),
'userModel' => 'User',
)
);
}
public function login() {
if ($this->Auth->login() || $this->Auth->loggedIn()) {
$this->redirect('/users/dashboard');
}else{
$this->layout='logindefault';
$this->set('title_for_layout', 'Account Login');
/*$this->Auth->logout();
$cookie = $this->Cookie->read('Auth.User'); */
if ($this->request->is('post')) {
if ($this->Auth->login() || $this->Auth->loggedIn()) {
if ($this->Session->check('Auth.User')){
$this->_setCookie($this->Auth->user('idUser'));
$this->redirect('/users/dashboard');
} }else {
$this->Session->setFlash('Incorrect Email/Password Combination');
}
}}
}
here is the code which i am trying to add ..
$mobileNo='+123456789';
if (strpos($mobileNo,'+') !== false) {
$mobileNo=str_replace("+", "",$mobileNo);
}
?
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>
I got one problem with showing error message to element.
Is there any option to turn on messages on place where is Html.ValidationMessageFor(model = model.ConfirmPassword). Becsoue for me it isn’t show up. I would like to have summary and near field information too not only red border. Any one know how to do it?
using (Ajax.BeginForm("CreateValidForm", "Test", new AjaxOptions { HttpMethod = "Post" })) {%> <div id="validationSummary1">
<%= Html.ValidationSummary(true)%> </div> <fieldset>
<legend>Fields</legend>
<div class="editor-label">
<%= Html.LabelFor(model => model.Name)%>
</div>
<div class="editor-field">
<%= Html.TextBoxFor(model => model.Name)%>
<%= Html.ValidationMessageFor(model => model.Name)%>
</div>
<div class="editor-label">
<%= Html.LabelFor(model => model.Email)%>
</div>
<div class="editor-field">
<%= Html.TextBoxFor(model => model.Email)%>
<%= Html.ValidationMessageFor(model => model.Email)%>
</div>
<div class="editor-label">
<%= Html.LabelFor(model => model.Password)%>
</div>
<div class="editor-field">
<%= Html.TextBoxFor(model => model.Password)%>
<%= Html.ValidationMessageFor(model => model.Password)%>
</div>
<div class="editor-label">
<%= Html.LabelFor(model => model.ConfirmPassword)%>
</div>
<div class="editor-field">
<%= Html.TextBoxFor(model => model.ConfirmPassword)%>
<%= Html.ValidationMessageFor(model => model.ConfirmPassword)%>
</div>
<p>
<input type="submit" value="Create" />
</p> </fieldset> <% } %> <%= Html.ClientSideValidation<ValidModel>()
.UseValidationSummary("validationSummary1", "Please fix the following problems:") %>
Here is link for sample project http://www.sendspace.com/file/m9gl54 .
I need to validate the contents of a C# method.
I do not care about syntax errors.
I do care about characters that will invalidate parsing of the rest of the code. For example:
method()
{
/* valid comment */
/* <-- bad
for (i..) {
}
for (i..) { <-- bad
}
I need to validate/fix any non-paired characters.
This includeds /* */, { }, and maybe others.
How should I go about this?
This is my code:
<html>
<head>
<title>scoreboard</title>
<script>
function calculate() {
var sum=0; var total=0;
for (var i=0; i < document.questions.group1.length; i++){
if (document.questions.group1[i].checked){
sum = parseInt(document.questions.group1[i].value)
total = parseInt(total + sum);}}
for (var i=0; i < document.questions.group2.length; i++){
if (document.questions.group2[i].checked){
sum = parseInt(document.questions.group2[i].value)
total = parseInt(total + sum);}}
for (var i=0; i < document.questions.group3.length; i++){
if (document.questions.group3[i].checked){
sum = parseInt(document.questions.group3[i].value)
total = parseInt(total + sum);}}
alert(total)
}
</script>
</head>
<body>
<form name="questions">
A:<br>
answer a1: <input type="radio" name="group1" value="0">
answer a2: <input type="radio" name="group1" value="1">
answer a3: <input type="radio" name="group1" value="2">
answer a4: <input type="radio" name="group1" value="3"><br>
B:<br>
answer b1: <input type="radio" name="group2" value="0">
answer b2: <input type="radio" name="group2" value="1">
answer b3: <input type="radio" name="group2" value="2">
answer b4: <input type="radio" name="group2" value="3"><br>
C:<br>
answer c1: <input type="radio" name="group3" value="0">
answer c2: <input type="radio" name="group3" value="1">
answer c3: <input type="radio" name="group3" value="2">
answer c4: <input type="radio" name="group3" value="3"><br><br>
<input type="button" value="total" onclick="calculate()">
</form>
</body>
</html>
How can I replace 'group[x]' in my code by a variable, so the three for-loops are replaced by one (because in reality there are a lot more questions and answers) ?
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.
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';
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>
`
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?
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 '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.
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
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
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
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 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 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 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
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"