how to show alert when user enter other then number value in textfield
By : Patrick
Date : March 29 2020, 07:55 AM
I hope this helps you . I have iphone app in which i enter any number value like 10 2 0 1 0.2 etc i want that instead of this if user enter any text it should alert that enter a number. , try this code: code :
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
if (textField==txtMobileNo)
{
[self validatePhone];
}else
{
[textField resignFirstResponder];
}
// called when 'return' key pressed. return NO to ignore.
return YES;
}
- (BOOL) validatePhone
{
NSString *phoneRegex = @"^+(?:[0-9] ?){6,14}[0-9]$";
NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", phoneRegex];
if ([phoneTest evaluateWithObject:txtMobileNo.text] == YES)
{
NSLog(@"proper phone nO ");
return YES;
}
else
{
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:nil message:@"Please,Enter Your Person proper phone no" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil ];
[alert show];
[alert release];
NSLog(@"phone no. not in proper format");
return NO;
[txtMobileNo becomeFirstResponder];
}
}
|
Display Alert if user enters 0 in the second EditText
By : user7614530
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I am making a calculator app in which I wanna show an alert is user divides anything by zero.REST all works fine but i user divides anything by zero an alert should b raised , Simple, Just add one more condition code :
div.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
a = e1.getText().toString();
b = e2.getText().toString();
AlertDialog.Builder a1 = new AlertDialog.Builder(c);
try{
if (a.equals("") || b.equals("") || b.equals("0")) {
........
.........
if (a.equals("") || b.equals("") {
.......
.......
}else if (b.equals("0")){
AlertDialog.Builder a1 = new AlertDialog.Builder(calci.this);
a1.setTitle("INVALID");
a1.setMessage("CAnnot divide by zero");
a1.setPositiveButton("YES",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int button1) {
// if this button is clicked, close
// current activity
dialog.cancel();
}
});
AlertDialog alertDialog = a1.create();
a1.show();
}else{
....
....
}
|
If Statement Needs to Alert the Number That the User Enters
By : Mykola Chornii
Date : November 17 2020, 09:01 AM
this one helps. Just change your alert to take the variable name out of the string being shown, like so: code :
window.alert(firstNumber + " is larger");
|
I want throw an alert after the user enters wrong password (the validation is from DB), I need to generate alert from my
By : Kim Marcus
Date : March 29 2020, 07:55 AM
wish helps you You are mixing client side and server side. And you are trying to forward to a HTML page which is not allowed: you can only forward to a servlet running in the same servlet context as the originating one. You must choose one: code :
response.setContentType("text/html");
pw.println("<script type=\"text/javascript\">");
pw.println("alert('Wrong password');");
pw.println("window.location.assign('/path/to/index.html');");
pw.println("</script>");
|
How to alert when user enters nothing?
By : Jim Bob QC
Date : March 29 2020, 07:55 AM
I wish this help you I'm making a JavaScript project and I want to alert when the user enters nothing in the prompt code :
function verifyage() {
var age = prompt("enter your age:", "");
if(isNaN(parseFloat(age))) { // check: if user entered a number/string/blank
alert("You entered nothing");
}
else {
var status = (age >= 18) ? "adult" : "minor";
if(status == "minor") {
alert("you are too young");
} else if (status == "adult") {
alert("you're in");
}
}
}
verifyage();
|