0

I have tried to validate input field by using a javascript/jQuery code. This is work fine with input type text and not support in number type. Input type 'number' does not work at all in FireFox.

My client wants the field to show number pad in mobile when the user starts to type and in the case of user try to type words should remove the words.

fiddle with example

HTML:

<input name="pricePerHour" id="pricePerHour" type="number" class="form-control" placeholder="Price Per Hour" required />
<br><br>
<input name="pricePerHour" id="costPerHour" type="text" class="form-control" placeholder="Cost Per Hour" required />

Javascript:

$("#pricePerHour,#costPerHour").on("keyup", function() {

  var valid = /^\d{0,4}(\.\d{0,2})?$/.test(this.value),
    val = this.value;

  if (!valid) {

    this.value = val.substring(0, val.length - 1);
  }
});
pTi
  • 357
  • 3
  • 13
  • I am sorry whats the complete error ? – Usman Iqbal Jun 20 '17 at 06:17
  • XMLHttpRequest cannot load http://52.15.167.221:9000/registerUser. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://php-sample.us-east-2.elasticbeanstalk.com' is therefore not allowed access. – pTi Jun 20 '17 at 06:24
  • 1
    You need to tackle this problem from the backend, it is possible that you are sending the request with wrong credentials. – Usman Iqbal Jun 20 '17 at 06:33
  • I think so, had to get the backend support – pTi Jun 20 '17 at 06:39

2 Answers2

0

A site hosted at php-sample.us-east-2.elasticbeanstalk.com cannot access api resources on www.52.15.167.221:9000 without proper cors headers + options endpoint.

More

This is for protecting the user. Please read up on cors https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS

basarat
  • 261,912
  • 58
  • 460
  • 511
0

CORS authorization is missing. If you are using apache , amend in config file of www.52.15.167.221:9000 such as httpd.conf or apache.conf or .htaccess

Put this line in anyone of the config file that i mentioned above. It should work.

Header set Access-Control-Allow-Origin "*"
Achilles
  • 411
  • 1
  • 5
  • 27