0

I have more than 5 card types and each card as different validation, when user change the card type, the reqpattern will change and i need to pass changed reqpattern in callonkeyup function. Please tell me how to pass changed reqpattern in callonkeyup function.

callonkeyup(this,'AccountNumber',this.getAttribute('reqpattern'))

<input type="tel" reqpattern="^[0-9]+\$" 
  onblur="callonkeyup(this,'AccountNumber',this.getAttribute('reqpattern'));" 
  value="" id="AccountNumber"/>
2
  • why don't you paste the work you've done so far so we can better help you... EDIT: thanks for edit @Jayesh Commented Apr 9, 2014 at 6:48
  • how user change the card type??? clicking some element or using dropdown etc... Commented Apr 9, 2014 at 6:51

2 Answers 2

1

Why not just pass the req pattern within the function call:

 <input type="tel" onblur="callonkeyup(this,'AccountNumber', '^[0-9]+\$');" value="" id="AccountNumber"/>
Sign up to request clarification or add additional context in comments.

1 Comment

Hi Reinder Wit, reqpattern is dynamic, it will be updating when user change the card types
0

I am not able to reproduce your issue with your code. I have tried with the below code snippet, Can you please check it at your hand?

<!DOCTYPE html>
<html>
<head> 
<title>Test</title>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
</head>
<body>
<input type="tel" reqpattern="^[0-9]+\$" 
  onblur="callonkeyup(this,'AccountNumber',this.getAttribute('reqpattern'));" 
  value="" id="AccountNumber"/>
<input type="tel" reqpattern="^[a-z]+\$" 
  onblur="callonkeyup(this,'AccountName',this.getAttribute('reqpattern'));" 
  value="" id="AccountName"/>

<script>
function callonkeyup(obj,txtType,rpattern)
{
    alert(obj);
    alert(txtType);
    alert(rpattern);
}

</script>
</body>
</html>

Let me know if any concern.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.