logo
down
shadow

to alert user if user enters other than a valid number value in each text fields and to alert user enter number if any t


to alert user if user enters other than a valid number value in each text fields and to alert user enter number if any t

By : user2956183
Date : November 22 2020, 10:54 AM
I think the issue was by ths following , , Try below code:
code :
 <!DOCTYPE html>
 <html>
 <body bgcolor = "eeeeee">
 <p> Add Section </p>
 <label>Fir No :</label>
 <input id="txt1"  type="text"/></br></br>
 <label>Sec No :</label>
 <input id="txt2"  type="text"/></br></br>
 <input type="button" name="Add" value="Add" onclick="addTwoNumber()"/>
 <p id="demo"></p>
 <script>
 function myFunction() {
 document.getElementById("demo").innerHTML = Date();
 }
 <!-- addition of two numbers-->

 function addTwoNumber(){
 var a = document.getElementById("txt1").value;
 var b = document.getElementById("txt2").value;
 if (a == "" || b == "")
 {
    alert('Please enter any number');
    return;
 }
 if (isNaN(a) || isNaN(b))
 {
    alert('Please enter any number');
    return;
 }
 var x = Number(a) + Number(b);
 document.getElementById("demo").innerHTML = "Add Value: " + x;
 }
 </script>

 </body>
 </html>


Share : facebook icon twitter icon
how to show alert when user enter other then number value in textfield

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

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

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

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?

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();
Related Posts Related Posts :
  • angular 6 Please add a @NgModule annotation
  • Trying to cast element ID to class selector in jQuery
  • Swipe JS - Display 3 Slides at a time
  • Jasmine test to call function when value is null
  • Redux reducer gets string instead of object
  • Keep chrome javascript running even if page reload
  • The event.target.value is not insert the userinput into a variable
  • Exporting HTML tables to Excel (.xls) in a separate sheet
  • Jquery tooltip on dialog close button
  • access variable inside anonymous function from outside
  • How come func is called from a function?
  • How to change add and remove active class in JavaScript
  • how to toggle a specific div in javascript
  • How to get all the values from multiple keys of an array of object?
  • jQuery bind() unbind() and on() and off()
  • regular expression to find DD Month YYYY from a string
  • How to upload files from web client (HTML/jQuery form) to your Dropbox folder
  • Backbone history and require.js issue
  • Confusion over Classical and Prototypal Inheritance Javascript
  • How to take screen shot of current webpage using Javascript/JQuery?
  • Store meridiem in a variable
  • class declared inside closure vs standard class without closure
  • javascript confirm box always return true
  • dynamically changing the size of font size based on text length using css and html
  • Node.js - Getting the host IP address while on Amazon EC2
  • Confusing CSS, can anyone explain please
  • How to install v8-profiler on Windows 8 (64 bit) using npm?
  • Resolve promise based on another promise
  • google maps adding overlay layer above UI and markers
  • Style specific letter?
  • RangeError: Maximum call stack size exceeded with array.slice
  • node rest client get with local variable
  • If condition not executes while mouse move fastly
  • Count the number of displayed elements in a HTML list
  • Locate JavaScript source code in Emacs
  • Clean, Modular Code vs MV* Frameworks
  • infinite scroll without loading image
  • Backbone: reverse collection order with comparator
  • What do printers ignore?
  • jQuery UI .tabs() Contentless tab?
  • Execute Javascript alert() after page (visually) loaded
  • JavaScript - duplicating array doesn't work
  • Excessive clickable area below image
  • JavaScript Regex: Replace |b| with <b>
  • Unexpected value change in 2D array in JavaScript
  • Function doesnt see parameter as a array of objects
  • jQuery fetch keypress event on chrome and IE
  • How to enable jquery validate localization?
  • Cassandra map collection returned by node.js Helenus looks odd
  • angular ng-repeat with multiple filter options
  • Selecting Children without ID or Class names
  • How to uncheck a group of checkboxes when another checkbox is checked
  • Is hiding content by Javascript or jQuery Worth trying
  • Load XUL resource using javascript
  • XML to HTML text area from server file system
  • set focus() on textbox on form onload
  • es lint '' is assigned a value but never used' eventhough i have used it
  • Can "name" attribute be used for custom VueJS components
  • Get innerHTML of content when it is clicked
  • HTTPS causes CSS animations to not load? Very confused
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org